CI-CD In Azure Web Apps Using Azure DevOps And Visual Studio

In this article we will see how to perform Continuous Integration and Continuous Delivery (Known as CI/CD) in Azure Web Apps using Azure DevOps (Previously known as VSTS) and Visual Studio. I will create a simple Web App using Visual Studio (I am using Visual Studio 2017 free community edition) and I will publish this Web App to Azure. I will enable Continuous Delivery in Visual Studio and then host the application in Azure DevOps using Git repository. I will make some code change in web application and commit the code to Git repository and will push the code to Azure DevOps. Continuous Integration will happen, and a new build will be deployed to Azure automatically.

It will reduce all our work load for build and deployment. We will see all the actions step by step.

Step 1 - Create a Web application in Visual Studio.

Please choose ASP.NET Web Application template.
 
CI-CD in Azure Web Apps using Azure DevOps and Visual Studio
 
We can choose MVC template.
 
CI-CD in Azure Web Apps using Azure DevOps and Visual Studio

Our application will be created shortly.

Step 2 - Publish the application to Azure

We can publish our application to Azure. You must install Azure SDK for this. If you do not have Azure SDK, please download it from this URL.

Right click the solution explorer and choose Publish.

CI-CD in Azure Web Apps using Azure DevOps and Visual Studio
 
It will open a new window and it will show 4 options. Please choose the first (App Service) option.
 
We are going to create a new Azure Web App. Select “Create New” option and click Publish button.
 
CI-CD in Azure Web Apps using Azure DevOps and Visual Studio 

It will ask for your Azure credentials and please login with your Azure account.

Please choose a name for your Web App and choose the name for your Hosting plan. In hosting plan, you must choose the location and size of your Web App. There are various plans available.

CI-CD in Azure Web Apps using Azure DevOps and Visual Studio
 
Available Plans.
 
CI-CD in Azure Web Apps using Azure DevOps and Visual Studio

We have already selected the size and chosen the name for our service plan. Now we can name the Web app.

Please click the “Create” button now.
 
CI-CD in Azure Web Apps using Azure DevOps and Visual Studio 

It will take some time to create a new Azure Web App and Service Plan and it will automatically publish to Azure.

Our Web App is ready now. This is a simple app.

CI-CD in Azure Web Apps using Azure DevOps and Visual Studio
 
Step 3 - Configure Continuous Delivery

We can now configure the Continuous Delivery. Please click “Configure” link

CI-CD in Azure Web Apps using Azure DevOps and Visual Studio
Please setup Azure DevOps or GitHub repository. Add our source files to source control. (Please click the link)
 
CI-CD in Azure Web Apps using Azure DevOps and Visual Studio
 
Please publish to Git Repo.
 
CI-CD in Azure Web Apps using Azure DevOps and Visual Studio
Please click “Publish Repository” button.
 
CI-CD in Azure Web Apps using Azure DevOps and Visual Studio
Repository will be created soon. Please click “Azure Pipelines”
 
CI-CD in Azure Web Apps using Azure DevOps and Visual Studio
 
Please choose the subscription and App Service name. Click OK button to start build process.
CI-CD in Azure Web Apps using Azure DevOps and Visual Studio
We will be notified with a message that Azure pipe lines started.

CI-CD in Azure Web Apps using Azure DevOps and Visual Studio 
 
After some time, pipe lines will be finished.

Please open Azure DevOps to see our Project repository and Pipelines. (DevOps Link)

You can see that new project repository is created in Azure DevOps.

CI-CD in Azure Web Apps using Azure DevOps and Visual Studio
 
Please click on the Project Pipelines.
 
CI-CD in Azure Web Apps using Azure DevOps and Visual Studio 
 
You can see that one manual build is created now.
 
CI-CD in Azure Web Apps using Azure DevOps and Visual Studio 
 
Step 4 - Continuous Integration and Continuous Delivery (CI/CD)
 
We can check the Continuous Integration and Continuous Delivery now. We can modify two files in our application. I have modified the Index.cshtml file. Also modified _Layout.cshmtl file.
 
CI-CD in Azure Web Apps using Azure DevOps and Visual Studio
 
Please commit the changes.
 
CI-CD in Azure Web Apps using Azure DevOps and Visual Studio
 
We can push the changes to Azure DevOps.
 
CI-CD in Azure Web Apps using Azure DevOps and Visual Studio
 
We will be notified with the below message.
 
CI-CD in Azure Web Apps using Azure DevOps and Visual Studio
 
We can check the Azure DevOps and find that our new build came automatically now.
 
CI-CD in Azure Web Apps using Azure DevOps and Visual Studio
 
It will take some time to finish the build and it will be automatically deployed to Azure Web App Service. We can see the status. Please note that only the modified changes will be affected with this build and deployment.
 
CI-CD in Azure Web Apps using Azure DevOps and Visual Studio
 
Please refresh the Azure Web Application. You can notice that our new changes will be applied in the Web App now. (If you still see the old screen, please clear the browser Cache)
 
CI-CD in Azure Web Apps using Azure DevOps and Visual Studio
 
In this application we saw how to create a Web Application in Visual Studio and we published the App to Azure and we created an Azure DevOps repository for our Web App and enabled the Continuous Delivery. We modified two Razor View files in our web application and commit and push the code changes to Azure DevOps. CI/CD feature automatically created a Batch build and deployed the application to Azure. Microsoft has really simplified the job for DevOps engineers.