Continuous DeploymentšŸš€ Using Azure DevOps PipelinesšŸŒˆ And .NET Project

In this article, we will see how to implement continuous deployment using Azure DevOps for a .NET project.

In my previous article, we saw what Continuous Integration is and how to set up Azure DevOps Pipelines for CI in a .NET project.
 
This article is an extension to my previous article on Continuous Integration using Azure DevOps Pipelines and .NET Project. For those who are new to this, I request you read my previous article on CI.
 
So, let's see how to set and build a pipeline for continuous deployment. 
 
Step 1 - Pipeline 
 
Log into your Azure DevOps account and choose Pipeline Releases. If it is your first time, you can also select the "New Pipeline" button as shown in the below screen.
 
Continuous DeploymentšŸš€ Using Azure DevOps PipelinesšŸŒˆ And .NET Project 
 
On the Template selection screen, search for IIS Web and select IIS Website Deployment. As we have .NET web application to be deployed, I have selected IIS Website Deployment here.
 
Continuous DeploymentšŸš€ Using Azure DevOps PipelinesšŸŒˆ And .NET Project
 
Now, we have to set up artifacts and stages for the deployment, so click on "Add an artifact", as shown in the below screen.
 
Continuous DeploymentšŸš€ Using Azure DevOps PipelinesšŸŒˆ And .NET Project
 
In our Continuous Integration section, we have already set up the Build for the deployment. Just select 'build' as a Source Type, select the project name and source build from the list, and click on 'Add'. 
 
Continuous DeploymentšŸš€ Using Azure DevOps PipelinesšŸŒˆ And .NET Project
Continuous DeploymentšŸš€ Using Azure DevOps PipelinesšŸŒˆ And .NET Project
 
There are three ways we can schedule the release trigger -

1. On a specific date time or day
2. Start when any check-in happens 
3. Manual trigger.
 
Continuous DeploymentšŸš€ Using Azure DevOps PipelinesšŸŒˆ And .NET Project
 
Select the scheduler, enable the trigger, and if you want to set a specific day and time, just set up by providing timings. 
 
Continuous DeploymentšŸš€ Using Azure DevOps PipelinesšŸŒˆ And .NET Project
 
Step 2 - Tasks 
 
As we have selected the IIS Deployment template, there are a few tasks and configurations to be done, as mentioned below.
  • IIS Deployment
  • IIS Web App Manage
  • IIS Web App Deploy 
Let's understand and configure one by one.
 
IIS Deployment
 
You have to specify the name for this deployment group job, and  configure deployment group first. A deployment group is a logical set of deployment target machines that have agents installed on each one.
 
It represents the physical environments, like 'Dev', 'Staging', or 'Production' etc.
 
Continuous DeploymentšŸš€ Using Azure DevOps PipelinesšŸŒˆ And .NET Project
 
To create a new deployment group, just click on "Add deployment group", enter the name as well as description, and click "Create".
 
Continuous DeploymentšŸš€ Using Azure DevOps PipelinesšŸŒˆ And .NET Project
Continuous DeploymentšŸš€ Using Azure DevOps PipelinesšŸŒˆ And .NET Project

It will generate a script to run on your virtual machine's PowerShell. To configure that system, click on "Use a personal access token in the script for authentication" and click on 'copy script to the clipboard'. 
 
Continuous DeploymentšŸš€ Using Azure DevOps PipelinesšŸŒˆ And .NET Project
 
Now, log into your virtual machine and run PowerShell from the Start menu.
 
Continuous DeploymentšŸš€ Using Azure DevOps PipelinesšŸŒˆ And .NET Project
 
Paste the script and press Enter. 
 
Continuous DeploymentšŸš€ Using Azure DevOps PipelinesšŸŒˆ And .NET Project
 
It will ask for "Deployment agent" selection; press Enter and wait for the next prompt.
 
 Continuous DeploymentšŸš€ Using Azure DevOps PipelinesšŸŒˆ And .NET Project
 
It will prompt you to choose the account to use the services. Press Enter and wait for the Deployment Group activation.
 
Continuous DeploymentšŸš€ Using Azure DevOps PipelinesšŸŒˆ And .NET Project
 
That's it. Your Deployment Group is up and running, you can see the Target status online. 
 
Continuous DeploymentšŸš€ Using Azure DevOps PipelinesšŸŒˆ And .NET Project

Save the changes and move on to the next tab.
 
Continuous DeploymentšŸš€ Using Azure DevOps PipelinesšŸŒˆ And .NET Project
 
IIS Web App Manage
 
Here, we have to configure the web app details, like website name or a physical path for the web application folder. 
 
My default website physical path was C:\inetpub\wwwroot. This, we have to mention in the physical path text box.
 
Continuous DeploymentšŸš€ Using Azure DevOps PipelinesšŸŒˆ And .NET Project
 
IIS Web App Deploy
 
In the last tab, we have to specify the package or folder details. That means from the Continuous Integration, whatever the latest package or zip files we get, we have to provide that so that the agent copies the files and deploys those to the specific location.
 
Continuous DeploymentšŸš€ Using Azure DevOps PipelinesšŸŒˆ And .NET Project

Once this is done, we can create the release manually for testing and test the deployment.
 
Continuous DeploymentšŸš€ Using Azure DevOps PipelinesšŸŒˆ And .NET Project
 
Step 3
 
Variables give us a convenient way to get the key data into various parts of the pipeline. There are system predefined variables and you can also create user-defined variables as per your need. For more details, click here.
 
Continuous DeploymentšŸš€ Using Azure DevOps PipelinesšŸŒˆ And .NET Project
 
Step 4
 
The Retention Policy will help you to keep the history of your last few releases. You can configure the days here.
 
Continuous DeploymentšŸš€ Using Azure DevOps PipelinesšŸŒˆ And .NET Project

Step 5
 
The following are the options we can use for managing the release name format.
 
Continuous DeploymentšŸš€ Using Azure DevOps PipelinesšŸŒˆ And .NET Project

 Step 6
 
Release and deployment: for starting the manual release, click on "Create release".
 
Continuous DeploymentšŸš€ Using Azure DevOps PipelinesšŸŒˆ And .NET Project
 
Select the state on which you want to deploy. Here, I have selected the live one.
 
Next, select the artifacts and version number you want to deploy and click "Create".
 
Continuous DeploymentšŸš€ Using Azure DevOps PipelinesšŸŒˆ And .NET Project
 
Your release pipeline is ready. Test it by deploying it manually. Click on "Deploy" and wait for the deploy release tasks to be executed.
 
Continuous DeploymentšŸš€ Using Azure DevOps PipelinesšŸŒˆ And .NET Project
Continuous DeploymentšŸš€ Using Azure DevOps PipelinesšŸŒˆ And .NET Project
 You can see the logs of all the task activities by clicking on the "Status".
 
Continuous DeploymentšŸš€ Using Azure DevOps PipelinesšŸŒˆ And .NET Project
Continuous DeploymentšŸš€ Using Azure DevOps PipelinesšŸŒˆ And .NET Project
Continuous DeploymentšŸš€ Using Azure DevOps PipelinesšŸŒˆ And .NET Project
 
Once it's succeeded, you can see all the changes live on the default website on Azure Virtual Machine.
 
I have already created the Azure VM and set up IIS for web application deployment. You can also create one and for details, you can refer to my article "Create And Manage Windows Virtual Machine On Azure Portal".
 
To host a website, we need IIS on Windows Virtual Machine and you can set up IIS on your virtual machine by following these steps here.
 
So here, I have hosted my web app on the default website that is hosted on the port 80 (default port) of IIS. Whenever we deploy, we can check the web pages by clicking on the "Browse website" option as shown in the below screen. 
 
Continuous DeploymentšŸš€ Using Azure DevOps PipelinesšŸŒˆ And .NET Project
 
History
 
After the deployment, you can view the history of the changeset, change type, comment, Date time, User and change details, anytime you want. 
 
Continuous DeploymentšŸš€ Using Azure DevOps PipelinesšŸŒˆ And .NET Project
 
I hope you like this article. I'm waiting for your feedback or comments in the comment box.