Tuesday 19 November 2019

Setup Azure CI/CD Pipelines using Visual Studio Part-2

In the previous article, we saw, how to configure CI/CD for a single project solution. In this article, we will see how to configure CI/CD for multiple project solutions.
Before going forward, please go through the previous article.
I’m not going to spend time on what is Azure DevOps and its feature, we are directly moving to CI/CD for multiple project solution. How can we configure this with the help of visual studio and TFS? We will see this step by step. Once we set up the Azure Pipeline then on each check-in it will build the application and deploy the changes on App Service according to the project.
To know about Azure DevOps and its other features, you can refer to the below blog.

For configuring the Azure DevOps CI/CD, you need the following tools.
  1.  Azure DevOps account
  2. Azure Portal Account
  3. Visual Studio 2012+(in my example I am using VS 2017 and 2019)

We will see how to configure CI/CD and setup Azure Pipeline using Azure DevOps.

Step 1:
Create a new project by using the Azure DevOps account. I am using Team Foundation version control, but you can use Git too.

Create Project on Azure DevOps

Step 2:
Configure the newly created project in Visual studio source control on your local system.

Configure Source Control

Step 3:
In the previous article, we created a new project with a solution in Visual Studio, now we are going to add another project under the same solution and add check-in the changes.

Create a Project with name CICD_App2

Added project in Solution control

CICD_App2 Running Successfully

Step 4:
Create a blank solution inside the CICD_App2 project folder.

Blank Solution

Creating a Blank Solution
Step 5:
Add CICD_App2 Project in the newly created blank solution.

Adding Project

Select .csproj file in order to add a project in the solution

Step 6:
Setup Azure Pipelines under the publish settings of your solution.

Setup Azure Pipeline
Step 7:
Wait for a few mins and then go the pipelines under Azure DevOps. You will see a new Pipeline created and the build of the project has started.

DevOps Pipeline Created

Step 8:
Check the Deployment Center on the Azure portal for your App Service, for which you have set up the Azure Pipeline in step 6.

Azure App Deployment Center

Step 9:
If there is no error in the build, then after some time your build has succeeded. It is taking a few mins. In my example, it takes up to 2 min.

Build Succeeded
Step 10:
It will also create a release as shown in the previous article, but in this article, I am going to show you how to create and configure a release manually.
Under the Releases, the option creates a new release.

New Release Pipeline
Step 11:
Select a template (Azure App Service Deployment) for stage and then add the Build Artifacts with Continuous Deployment Trigger.

Template Selection


Continuous Deployment Trigger
Step 12:
Create a task under the task option, add the options correctly when you are creating a task.

Create Task
Now, you are ready to create a release.

Creating Release Option

Create Release

Step 13:
After the release created it will start to deploy the changes on the App Service.

Released Successfully
Step 14:
Check the App by using URL and you will see the application has deployed.

App Service URL after First Release

Step 15:
Change anything in the application, check-in the changes and see Azure DevOps will build the solution and release the changes.

Heading change

After build completed, new changes are deployed

Step 16:
Now we are going to change the code in both projects and check-in those in the single check-in. Then we will see how both projects are building separately and deploy the changes in different app services accordingly.

Changes in Default.aspx pages under both project

The build has started for both projects

Released the changes of both projects

Changes have deployed

Note: We can see all Releases under Deployment Center on Azure Portal.
We need a separate .sln file to configure the CICD for each project.