In this hands-on lab you will deploy a simple website to Azure App Services using GitHub Actions.
-
Create a fork of this repository (if you haven'nt done so) by clicking the
Forkbutton at the top right corner. -
Open setup-azure.sh and modify the
appName. The name will be part of the URL and must be unique. Replacexyzfor 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' -
Commit your changes to the forked repository.
-
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. -
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
-
Run setup-azure.sh and copy the publish profile at the end of the script.
$ ./setup-azure.shVerify that your app is running by opening the URL https://xyz-demo-shop.azurewebsites.net (replace
xyz-demo-shopwith theappNameyou set in your script.)
-
Create a new Environment under
Settings|Environments|New environment. Enter the nameProdand clickConfigure environment. -
Add yourself as a required reviewer and click
Save protection rule:
-
Under
Environment secrets, add a new secret calledAZUREAPPSERVICE_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
-
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.
-
Run the workflow: Go to
Actionsand selectDeploy-Azure. Open theRun workflowmenu and clickRun workflow:
-
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:
Select the
Prodenvironment and selectApprove and deploy:
-
Validate: Wait until the deployment is complete.
Refresh your browser with URL https://xyz-demo-shop.azurewebsites.net (replace
xyz-demo-shopwith theappNameyou set in your script.) or open a new browser to validate your deployment.
-
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