Continuous Deployment🚀 Using Azure DevOps Pipelines🌈 And .NET Project

Before reading this article, please read the previous articles so that you can understand Azure DevOps. The list of previous articles is provided below.

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 the .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.No release pipelines found
  • On the Template selection screen, search for IIS Web and select IIS Website Deployment. As we have a .NET web application to be deployed, I have selected IIS Website Deployment here.IIS website deployment
  • Now, we have to set up artifacts and stages for the deployment, so click on "Add an artifact", as shown in the below screen.
    All pipelines
  • In our ContinuousIntegration 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'.Add an artifac
    Build

There are three ways we can schedule the release trigger

  • On a specific date time or day
  • Start when any check-in happens
  • Manual trigger.
    Schedule
  • Select the scheduler, enable the trigger, and if you want to set a specific day and time, just set up by providing timings.
    Schedule release trigger

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 the 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.
    IIS deployment
  • To create a new deployment group, just click on "Add deployment group", enter the name as well as the description, and click "Create".
    Deployment groups
    Create
  • 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'.Copy script to the clipboard
  • Now, log into your virtual machine and run PowerShell from the Start menu.
    Enter your credentials
  • Paste the script and press Enter.
    Window powershell
  • It will ask for the "Deployment agent" selection; press Enter and wait for the next prompt.
    Administrator window powershell
  • It will prompt you to choose the account to use the services. Press Enter and wait for the Deployment Group activation.
    Enter user account to use for the service
  • That's it. Your Deployment Group is up and running, you can see the Target status online.
    Deployment groups
  • Save the changes and move on to the next tab.
    Deployment target

IIS Web App Manage

  • Here, we have to configure the web app details, like the 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.
    IIs web app manage

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.
    IIS web app deploy
  • Once this is done, we can create the release manually for testing and test the deployment.
    Release

Step 3. Variables Setup

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.

Variable

Step 4. Retention Policy

The Retention Policy will help you to keep the history of your last few releases. You can configure the days here.

Retention

Step 5. Release Naming

The following are the options we can use for managing the release name format.

Option

Step 6. Release and Deployment

  • Release and deployment: To start the manual release, click on "Create release".
    Click on create release
  • Select the state in 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".
    Click on create
  • Your release pipeline is ready. Test it by deploying it manually. Click on "Deploy" and wait for the deploy release tasks to be executed.
    Deploy
    Deploy release
  • You can see the logs of all the task activities by clicking on "Status".
    Clicking on status
    MyVM
    Pipeline
  • 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
    Default web site home

History

After the deployment, you can view the history of the changeset, change type, comment, Date time, User, and change details, anytime you want.

History

I hope you like this article. I'm waiting for your feedback or comments in the comment box.

If you want to read more about Azure DevOps, the next articles in this series are listed below.