In today’s post I will show how to enable continuous integration (CI) with GitHub and the Azure App Service.
To configure CI with GitHub and Azure App Services we will need the following:
- An existing GitHub account.
- An existing GitHub repository.
- An existing Azure subscription.
- An existing Azure Application Service.
The steps I will show are as follows:
Go to your App Service. Under Deployment select Deployment Center.
In Deployment Center, you will see a number of options of different source control repositories you can synchronize tour app service with:
Select GitHub (1), then Authorize (2).
When the authorization dialog opens, click on Authorize AzureAppService.
In the next screen, enter the GitHub password and Confirm Password.
Back in the Deployment Center, you will see your GitHub account name under the GitHub selection.
In the build provider, select App Service build service.
(The other option Azure Pipelines will require an added service so we will defer to a later post.)
Select Continue. The configure screen now shows.
In the Configure screen, enter the following:
- GitHub account or organization account.
- GitHub repository name (your source project name).
- Repository branch to monitor.
Click Finish on the Summary screen.
A few seconds later you will see the following screen confirming successful integration of the App Service and GitHub:
[Note: If you get the following error
“Failed to set up deployment”
Then check your App Service publish settings from the deployment host (Azure CLI or Visual Studio). If any of the settings such as Resource Group, App Plan, Credentials etc. have changed since the last deployment, then redeploy the App Service with the updated settings and retry the above integration.]
As a useful aside, clicking on Show Logs in the confirmation screen beside the Generating deployment script activity will show the actual deployment script employed:
Using the following command to generate deployment script: 'azure site deploymentscript -y --no-dot-deployment -r "D:\home\site\repository" -o "D:\home\site\deployments\tools" --aspNetCore "D:\home\site\repository\MyApp.csproj" --solutionFile "D:\home\site\repository\MyApp.sln"'. Project file path: .\MyApp.csproj Solution file path: .\MyApp.sln Generated deployment script files
Beside the Running deployment command… activity, clicking on Show Logs will display the deployment script employed.
To test the continuous integration trigger from the remote GitHub repository, go back to your solution in Visual Studio 2017, then make a change to the web application project.
Push changes to the GitHub repository. In GitHub confirm the changes to the branch have been applied:
Push changes to the GitHub repository.
In GitHub confirm the changes to the branch have been applied:
In the Azure Portal, return to the Application Service Deployment Centre.
You will notice the CHECKIN MESSAGE column is identical to your most recent GitHub commit message.
Check the STATUS column.
If the status shows as Success (Active), then your deployment has been triggered and is successful without errors!
The activity log will show:
If you download the diagnostic dumps and open log.txt, you will see at the bottom of the file:
Now test by browsing to the web site:
I hope this has been useful and informative post to discovering how apply continuous integration of your GitHub projects with your Azure Application Service.