{"id":16519458,"url":"https://github.com/root-11/skills-deploy-to-azure","last_synced_at":"2026-06-05T02:31:23.489Z","repository":{"id":198015099,"uuid":"699881876","full_name":"root-11/skills-deploy-to-azure","owner":"root-11","description":"My clone repository","archived":false,"fork":false,"pushed_at":"2023-11-01T17:24:35.000Z","size":331,"stargazers_count":0,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-02T22:27:09.060Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/root-11.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-03T14:23:34.000Z","updated_at":"2023-10-03T14:24:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"478bb7cc-0011-41b2-a348-c3a31a18e79a","html_url":"https://github.com/root-11/skills-deploy-to-azure","commit_stats":null,"previous_names":["root-11/skills-deploy-to-azure"],"tags_count":0,"template":false,"template_full_name":"skills/deploy-to-azure","purl":"pkg:github/root-11/skills-deploy-to-azure","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/root-11%2Fskills-deploy-to-azure","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/root-11%2Fskills-deploy-to-azure/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/root-11%2Fskills-deploy-to-azure/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/root-11%2Fskills-deploy-to-azure/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/root-11","download_url":"https://codeload.github.com/root-11/skills-deploy-to-azure/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/root-11%2Fskills-deploy-to-azure/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33927314,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-05T02:00:06.157Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T16:46:50.865Z","updated_at":"2026-06-05T02:31:23.473Z","avatar_url":"https://github.com/root-11.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cheader\u003e\n\n\u003c!--\n  \u003c\u003c\u003c Author notes: Course header \u003e\u003e\u003e\n  Include a 1280x640 image, course title in sentence case, and a concise description in emphasis.\n  In your repository settings: enable template repository, add your 1280x640 social image, auto delete head branches.\n  Add your open source license, GitHub uses MIT license.\n--\u003e\n\n# Deploy to Azure\n\n_Create two deployment workflows using GitHub Actions and Microsoft Azure._\n\n\u003c/header\u003e\n\n\u003c!--\n  \u003c\u003c\u003c Author notes: Step 3 \u003e\u003e\u003e\n  Start this step by acknowledging the previous step.\n  Define terms and link to docs.github.com.\n--\u003e\n\n\n## Step 3: Spin up an environment based on labels\n\n_Nicely done! :heart:_\n\nGitHub Actions is cloud agnostic, so any cloud will work. We'll show how to deploy to Azure in this course.\n\n**What are _Azure resources_?** In Azure, a resource is an entity managed by Azure. We'll use the following Azure resources in this course:\n\n- A [web app](https://docs.microsoft.com/en-us/azure/app-service/overview) is how we'll be deploying our application to Azure.\n- A [resource group](https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/overview#resource-groups) is a collection of resources, like web apps and virtual machines (VMs).\n- An [App Service plan](https://docs.microsoft.com/en-us/azure/app-service/overview-hosting-plans) is what runs our web app and manages the billing (our app should run for free).\n\nThrough the power of GitHub Actions, we can create, configure, and destroy these resources through our workflow files.\n\n### :keyboard: Activity 1: Set up a personal access token (PAT)\n\nPersonal access tokens (PATs) are an alternative to using passwords for authentication to GitHub. We will use a PAT to allow your web app to pull the container image after your workflow pushes a newly built image to the registry.\n\n1. Open a new browser tab, and work on the steps in your second tab while you read the instructions in this tab.\n2. Create a personal access token with the `repo` and `read:packages` scopes. For more information, see [\"Creating a personal access token.\"](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token)\n3. Once you have generated the token we will need to store it in a secret so that it can be used within a workflow. Create a new repository secret named `CR_PAT` and paste the PAT token in as the value.\n4. With this done we can move on to setting up our workflow.\n\n**Configuring your Azure environment**\n\nTo deploy successfully to our Azure environment:\n\n1. Create a new branch called `azure-configuration` by clicking on the branch dropdown on the top, left hand corner of the `Code` tab on your repository page.\n2. Once you're in the new `azure-configuration` branch, go into the `.github/workflows` directory and create a new file titled `spinup-destroy.yml` by clicking **Add file**.\n\nCopy and paste the following into this new file:\n\n```yaml\nname: Configure Azure environment\n\non:\n  pull_request:\n    types: [labeled]\n\nenv:\n  IMAGE_REGISTRY_URL: ghcr.io\n\n  AZURE_RESOURCE_GROUP: cd-with-actions\n  AZURE_APP_PLAN: actions-ttt-deployment\n  AZURE_LOCATION: '\"Central US\"'\n  ###############################################\n  ### Replace \u003cusername\u003e with GitHub username ###\n  ###############################################\n  AZURE_WEBAPP_NAME: \u003cusername\u003e-ttt-app\n\njobs:\n  setup-up-azure-resources:\n    runs-on: ubuntu-latest\n    if: contains(github.event.pull_request.labels.*.name, 'spin up environment')\n    steps:\n      - name: Checkout repository\n        uses: actions/checkout@v3\n\n      - name: Azure login\n        uses: azure/login@v1\n        with:\n          creds: ${{ secrets.AZURE_CREDENTIALS }}\n\n      - name: Create Azure resource group\n        if: success()\n        run: |\n          az group create --location ${{env.AZURE_LOCATION}} --name ${{env.AZURE_RESOURCE_GROUP}} --subscription ${{secrets.AZURE_SUBSCRIPTION_ID}}\n\n      - name: Create Azure app service plan\n        if: success()\n        run: |\n          az appservice plan create --resource-group ${{env.AZURE_RESOURCE_GROUP}} --name ${{env.AZURE_APP_PLAN}} --is-linux --sku F1 --subscription ${{secrets.AZURE_SUBSCRIPTION_ID}}\n\n      - name: Create webapp resource\n        if: success()\n        run: |\n          az webapp create --resource-group ${{ env.AZURE_RESOURCE_GROUP }} --plan ${{ env.AZURE_APP_PLAN }} --name ${{ env.AZURE_WEBAPP_NAME }}  --deployment-container-image-name nginx --subscription ${{secrets.AZURE_SUBSCRIPTION_ID}}\n\n      - name: Configure webapp to use GHCR\n        if: success()\n        run: |\n          az webapp config container set --docker-custom-image-name nginx --docker-registry-server-password ${{secrets.CR_PAT}} --docker-registry-server-url https://${{env.IMAGE_REGISTRY_URL}} --docker-registry-server-user ${{github.actor}} --name ${{ env.AZURE_WEBAPP_NAME }} --resource-group ${{ env.AZURE_RESOURCE_GROUP }} --subscription ${{secrets.AZURE_SUBSCRIPTION_ID}}\n\n  destroy-azure-resources:\n    runs-on: ubuntu-latest\n\n    if: contains(github.event.pull_request.labels.*.name, 'destroy environment')\n\n    steps:\n      - name: Checkout repository\n        uses: actions/checkout@v3\n\n      - name: Azure login\n        uses: azure/login@v1\n        with:\n          creds: ${{ secrets.AZURE_CREDENTIALS }}\n      - name: Destroy Azure environment\n        if: success()\n        run: |\n          az group delete --name ${{env.AZURE_RESOURCE_GROUP}} --subscription ${{secrets.AZURE_SUBSCRIPTION_ID}} --yes\n```\n\n3. Click **Commit changes...** and select `Commit directly to the azure-configuration branch.` before clicking **Commit changes**.\n4. Go to the Pull requests tab of the repository.\n5. There should be a yellow banner with the `azure-configuration` branch where you can click **Compare \u0026 pull request**.\n6. Set the title of the Pull request to: `Added spinup-destroy.yml workflow` and click `Create pull request`.\n\nWe will cover the key functionality below and then put the workflow to use by applying a label to the pull request.\n\nThis new workflow has two jobs:\n\n1. **Set up Azure resources** will run if the pull request contains a label with the name \"spin up environment\".\n2. **Destroy Azure resources** will run if the pull request contains a label with the name \"destroy environment\".\n\nIn addition to each job, there's a few global environment variables:\n\n- `AZURE_RESOURCE_GROUP`, `AZURE_APP_PLAN`, and `AZURE_WEBAPP_NAME` are names for our resource group, app service plan, and web app, respectively, which we'll reference over multiple steps and workflows\n- `AZURE_LOCATION` lets us specify the [region](https://azure.microsoft.com/en-us/global-infrastructure/regions/) for the data centers, where our app will ultimately be deployed.\n\n**Setting up Azure resources**\n\nThe first job sets up the Azure resources as follows:\n\n1. Logs into your Azure account with the [`azure/login`](https://github.com/Azure/login) action. The `AZURE_CREDENTIALS` secret you created earlier is used for authentication.\n1. Creates an [Azure resource group](https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/overview#resource-groups) by running [`az group create`](https://docs.microsoft.com/en-us/cli/azure/group?view=azure-cli-latest#az-group-create) on the Azure CLI, which is [pre-installed on the GitHub-hosted runner](https://help.github.com/en/actions/reference/software-installed-on-github-hosted-runners).\n1. Creates an [App Service plan](https://docs.microsoft.com/en-us/azure/app-service/overview-hosting-plans) by running [`az appservice plan create`](https://docs.microsoft.com/en-us/cli/azure/appservice/plan?view=azure-cli-latest#az-appservice-plan-create) on the Azure CLI.\n1. Creates a [web app](https://docs.microsoft.com/en-us/azure/app-service/overview) by running [`az webapp create`](https://docs.microsoft.com/en-us/cli/azure/webapp?view=azure-cli-latest#az-webapp-create) on the Azure CLI.\n1. Configures the newly created web app to use [GitHub Packages](https://help.github.com/en/packages/publishing-and-managing-packages/about-github-packages) by using [`az webapp config`](https://docs.microsoft.com/en-us/cli/azure/webapp/config?view=azure-cli-latest) on the Azure CLI. Azure can be configured to use its own [Azure Container Registry](https://docs.microsoft.com/en-us/azure/container-registry/), [DockerHub](https://docs.docker.com/docker-hub/), or a custom (private) registry. In this case, we'll configure GitHub Packages as a custom registry.\n\n**Destroying Azure resources**\n\nThe second job destroys Azure resources so that you do not use your free minutes or incur billing. The job works as follows:\n\n1. Logs into your Azure account with the [`azure/login`](https://github.com/Azure/login) action. The `AZURE_CREDENTIALS` secret you created earlier is used for authentication.\n1. Deletes the resource group we created earlier using [`az group delete`](https://docs.microsoft.com/en-us/cli/azure/group?view=azure-cli-latest#az-group-delete) on the Azure CLI.\n\n### :keyboard: Activity 2: Apply labels to create resources\n\n1. Edit the `spinup-destroy.yml` file in your open pull request and replace any `\u003cusername\u003e` placeholders with your GitHub username. Commit this change directly to the `azure-configuration` branch.\n1. Back in the Pull request, create and apply the `spin up environment` label to your open pull request\n1. Wait for the GitHub Actions workflow to run and spin up your Azure environment. You can follow along in the Actions tab or in the pull request merge box.\n1. Wait about 20 seconds then refresh this page (the one you're following instructions from). [GitHub Actions](https://docs.github.com/en/actions) will automatically update to the next step.\n\n\u003cfooter\u003e\n\n\u003c!--\n  \u003c\u003c\u003c Author notes: Footer \u003e\u003e\u003e\n  Add a link to get support, GitHub status page, code of conduct, license link.\n--\u003e\n\n---\n\nGet help: [Post in our discussion board](https://github.com/orgs/skills/discussions/categories/deploy-to-azure) \u0026bull; [Review the GitHub status page](https://www.githubstatus.com/)\n\n\u0026copy; 2023 GitHub \u0026bull; [Code of Conduct](https://www.contributor-covenant.org/version/2/1/code_of_conduct/code_of_conduct.md) \u0026bull; [MIT License](https://gh.io/mit)\n\n\u003c/footer\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froot-11%2Fskills-deploy-to-azure","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froot-11%2Fskills-deploy-to-azure","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froot-11%2Fskills-deploy-to-azure/lists"}