Skip to content

Latest commit

 

History

History
89 lines (56 loc) · 4.65 KB

Deploy_to_Azure_App_Service.md

File metadata and controls

89 lines (56 loc) · 4.65 KB

Hands-on: Deploy to Azure App Service

In this hands-on lab you will deploy a simple website to Azure App Services using GitHub Actions.

  1. Create a fork of this repository (if you haven'nt done so) by clicking the Fork button at the top right corner.

  2. Open setup-azure.sh and modify the appName. The name will be part of the URL and must be unique. Replace xyz for example with your username.

    appName=xyz-demo-shop
    location=westeurope

    Also select the datacenter to host the app service by setting the location (westeuope, centralus, eastasia, australia, etc.). If unsure what the best region is, proceed to step 4 and execute the following command to get a list of all available locations:

    $ az account list-locations --query '[].name'
  3. Commit your changes to the forked repository.

  4. Open cloud shell
    The easiest way to get started is by opening the Azure Cloud Shell at https://shell.azure.com. You can alternately use the Azure CLI if you've installed it locally. (For more information on Cloud Shell, see the Cloud Shell Overview.

  5. Clone your fork inside the cloud shell and make setup-azure.sh executable:

    $ git clone https://github.com/wulfland/AccelerateDevOps.git
    $ cd AccelerateDevOps/ch9_release/
    $ chmod +x setup-azure.sh
    
  6. Run setup-azure.sh and copy the publish profile at the end of the script.

    $ ./setup-azure.sh

    Verify that your app is running by opening the URL https://xyz-demo-shop.azurewebsites.net (replace xyz-demo-shop with the appName you set in your script.)

    09_001_Validate-setup
  7. Create a new Environment under Settings | Environments | New environment. Enter the name Prod and click Configure environment.

  8. Add yourself as a required reviewer and click Save protection rule:

    09_02_Create-environment
  9. Under Environment secrets, add a new secret called AZUREAPPSERVICE_PUBLISHPROFILE. Paste the value from step 6 or run the following command to get the publishing profile again:

    $ az webapp deployment list-publishing-profiles \
     --resource-group $rgname \
     --name $appName \
     --xml
  10. Open .github/workflows/Deploy-Azure.yml and ajust the app name at the top of the file:

    env:
     appName: xyz-demo-shop

    Commit the file to your fork.

  11. Run the workflow: Go to Actions and select Deploy-Azure. Open the Run workflow menu and click Run workflow:

    09_003_Run-workflow
  12. Approve: The workflow runs some time to build the app. You'll get notified if the build job completes and the approval is required. Click Review deployments:

    09_004_Approve-workflow

    Select the Prod environment and select Approve and deploy:

    09_005_Approve
  13. Validate: Wait until the deployment is complete.

    09_006_Progress

    Refresh your browser with URL https://xyz-demo-shop.azurewebsites.net (replace xyz-demo-shop with the appName you set in your script.) or open a new browser to validate your deployment.

    09_007_Validate
  14. Clean up: If you are done you can clean up all Azure resource to save money. Delete the resource group by executing the following script from the cloud shell:

    $ ./destroy-azure.sh