Continuous Deployment on Azure with Visual Studio 2019 and GitHub
Tags: azure, dotnet, github, visualstudio
Published: 2019-10-29 23:14:31

###**Continuous deployment**###
 
When talking about continuous deployment we refer to the following definition:

*"Continuous deployment is the ability to get changes of all types—including new features, configuration changes, bug fixes and experiments—into production, or into the hands of users, safely and quickly in a sustainable way"*. Jez Humble. 

This definition means that we have several advantages in making use of continuous implementation, among these:

   • Automation of the software publishing process.
   • Improve development productivity.
   • Find and fix errors faster.
   • Deliver updates to users faster.

To understand these concepts quickly and easily, we will carry out the process of continuous implementation of a web application whose development is carried out from Visual Studio 2019, then associate this project with a GitHub repository and with that repository perform continuous implementation towards Azure Web App where our application will be hosted.

**Web projects supported in App Service**

Before reviewing our implementation example, something very important to mention are the types of projects with which we can carry out continuous implementation with Azure Web App, in this case, Azure supports the following frameworks for web development:

• .NET
• Node.js
• PHP
• Java
• Python
• HTML
• Docker

In this case, our example will be a web application made through the framework: ASP.NET Core 2.2 from Visual Studio 2019. However, for any type of project and / or any IDE of preference, the process will be similar.

#PART 1: Associate project in Visual Studio with GitHub#

**.NET Core 2.2 workload in Visual Studio**

Visual Studio: [https://visualstudio.microsoft.com/downloads/](https://visualstudio.microsoft.com/downloads/)

Considering that we have the following workload in Visual Studio 2019:

![](https://thepracticaldev.s3.amazonaws.com/i/g0lheylkb4rpdhdmokla.jpg)

The first thing to do is install the GitHub extension for Visual Studio:

Extension: [https://visualstudio.github.com/](https://visualstudio.github.com/)

To do this, Visual Studio must be closed in order to install the extension since they are changes that are made to the Microsoft IDE. 

**.NET Core 2.2 in Visual Studio**

To do this, Visual Studio must be closed in order to install the extension since they are changes that are made to the Microsoft IDE.

![](https://thepracticaldev.s3.amazonaws.com/i/9spzl5oksi55ibb59zmu.jpg)
 
We will proceed to associate the solution that contains the project to a repository in GitHub, for this we right click on the solution and select add solution to the source code control:

![](https://thepracticaldev.s3.amazonaws.com/i/dq0bbqvtpehe1xfuxtz7.jpg)
 
Later we go to the Team Explorer view and then to the Synchronization section:

![](https://thepracticaldev.s3.amazonaws.com/i/aaneywlrexb9i49fs7iz.jpg) 

In this case we have the options to publish our project in an Azure DevOps account and in a GitHub account.

When selecting Publish to GitHub, you will be asked to log in if it is the first time and create the repository to which we want to associate the project:

![](https://thepracticaldev.s3.amazonaws.com/i/8m3yqrercaec5mardpcc.jpg)
 
A short time later our project is associated with the repository that we just created. We can check that directly from GitHub:

![](https://thepracticaldev.s3.amazonaws.com/i/jurggj996v0hqtittjjo.jpg)

From now on whenever we want to save the changes we make we can go to the Changes section in Team Explorer:
 
![](https://thepracticaldev.s3.amazonaws.com/i/ys1k7mjrer5dive3cfp1.jpg)

And in the Synchronize section confirm the output changes:
 
![](https://thepracticaldev.s3.amazonaws.com/i/ac2wpks2kbro37c5fqzp.jpg)

#PART 2: Continuous deployment between Azure Web App and GitHub repository#

As a first point it is necessary to have a Web App service in Azure, for this we can create it from the Azure portal in case we do not have an established application.

As we can see in the image, the name of the application will also be used to define the domain name in order to access the website that you want to create. Azure provides us with a subdomain with azurewebsites.net.

Also, Azure allows us to specify the execution stack, in this case we select .NET Core 2.2 which is the version that our application uses.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/d090mdaao0pneh5m9ky7.jpg)

The creation of this service usually takes between 30 and 60 seconds.

![](https://thepracticaldev.s3.amazonaws.com/i/spfluza6iept4uklr0u7.jpg)

Now that we have the service created, we are going to the resource in the Azure portal. On the application page, select Deployment Center from the menu on the left.

![](https://thepracticaldev.s3.amazonaws.com/i/226dt429wgu09rlsc2c3.jpg)
 
On the implementation center page, we select GitHub and then log in and select Authorize.

![](https://thepracticaldev.s3.amazonaws.com/i/ave247uz6poqi2reyel2.jpg)

As for GitHub, on the page to compile the provider, select App Service build service and then Continue.

![](https://thepracticaldev.s3.amazonaws.com/i/jc0wmv2uw1tseu4vpgtb.jpg)
 
Then on the configuration page:

We display the menu and select the *organization*, the *repository* and the *branch* that you want to implement continuously.

![](https://thepracticaldev.s3.amazonaws.com/i/74plg2qbj00kawsmlkr6.jpg)
 
After setting up the compilation provider, review the settings on the summary page and select Finish.

![](https://thepracticaldev.s3.amazonaws.com/i/veq00aha2tdvrzna7ii9.jpg)
 
From now on the new confirmations of the selected repository and branch are now continuously implemented in your App Service application. You can track confirmations and implementations on the implementation center page.

![](https://thepracticaldev.s3.amazonaws.com/i/9tuqo3bnd7bos9xu1ub7.jpg)
 
#**ADDITIONAL COMMENTS**#

** Disabling continuous deployment**

To disable continuous deployment, select Disconnect at the top of the Deployment Center page of the application.

![](https://thepracticaldev.s3.amazonaws.com/i/s4jjiucgjjg7vsvrvg9s.jpg)

To continue with the continuous implementation later, we repeat the association process to the GitHub repository from the Deployment Center page of the application.

**Other sources of repositories**

In addition to GitHub, with Azure Web App we can also carry out continuous deployment from the following sources:

• Bitbucket
• Local Git
• OneDrive
• Dropbox
• External
• FTP