Continuous deployment
Azure Azure App Services CICD Continuous Deployment Continuous Integration DevOps GitHub Kudu

Enabling Continuous Integration with GitHub and Azure App Service

In today’s post I will show how to enable continuous integration (CI) with GitHub and the Azure App Service.

The Azure App Service has a built-in capability to provide continuous integration with an existing source control repository. Within an Azure App Service web application, we can have our application source code stored as a local Git repository, an Azure Git repository, or as an external GitHub repository.

In addition, we can use one of two source code build providers, the App Service Kudu Service, or an Azure DevOps Build Pipeline.  

With the above variations, we have enough flexibility to leverage the power of Azure App Services to provide us with continuous integration from our GitHub source code repository.

Configuring Continuous Integration between GitHub and Azure App Services

To configure CI with GitHub and Azure App Services we will need the following:

  1. An existing GitHub account.
  2. An existing GitHub repository.
  3. An existing Azure subscription.
  4. 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.

Select Continue

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 the following parameters:

In the Configure screen, enter the following:

  1. GitHub account or organization account.
  2. GitHub repository name (your source project name).
  3. Repository branch to monitor.

Click Continue.

Click Finish on the Summary screen.

Checking the Status of the Integration

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.

In the next section, I will show how to trigger the build from the GitHub repository.

Triggering the Continuous Integration Build

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.

Save changes.

Commit changes.

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:

2019-12-26T09:37:59.8449306Z,Deployment successful.,2206ae50-ac29-481f-835e-79a98d82c4c4,0

Now test by browsing to the web site:

http://[app name]

We have seen how to setup continuous integration between a GitHub repository and Azure App Service. In addition, I showed how to trigger the build of the web application from changes to our GitHub source repository to deployment of the application in the Azure App Service.

That’s all for today’s post.

I hope this post has been useful and informative.

Social media & sharing icons powered by UltimatelySocial