19
DecBuilding CI/CD Pipeline with the Azure DevOps
Azure DevOps Pipelines provide you the option to do your CI builds for any platform and any tool or language. Azure DevOps Pipelines provides a web interface where you can create jobs that contain steps that need to take place to create a production artifact for your software. The build automation pipelines allow you to trigger from any external repository like GitHub, SVN, or your local Git server or Azure DevOps repositories. The triggers will then fire the build according to the definition you created. Besides, Azure DevOps also provides the following options for automation
Build automation
Deployment automation
You can very easily deploy your application to Google Cloud, AWS, Azure Cloud or on your on-premises services in many ways. When you use the whole suite of Azure DevOps, so you use the boards to track the work, the repos to track the work, the version control system, and when you also use the build and release tools, you will get full traceability out of the box. This is great for compliance. If you prefer to use other tools, you can all plug them into the integration points that are available.
What is CI/CD?
Continuous integration and continuous delivery (CI/CD) is backbone of DevOps. It helps fast software development and deployment to enable continuous delivery of value to end users by achieving incremental software delivery. Continuous integration (i.e. CI) is an automated way to build, package, and test the applications. These builds are passed as inputs to the CD pipeline.

Continuous delivery (i.e. CD) automates the delivery of applications to selected infrastructure environments like development, UAT, production. With Azure DevOps, you deploy any software on any platform.
Steps to create CI/CD pipeline
Let us see the steps to implement build automation and deployment automation with Azure DevOps Pipelines.
Create Your Azure DevOps Organization
The first step is to navigate to https://dev.azure.com
and sign-in to Azure DevOps. You need to create at least an organization to store your projects, your repositories.

Figure 2. Create an Azure Organization
Please visit Microsoft’s documentation for more advance organization scenarios.
Create a Project
Please create an Azure DevOps project by selecting values like visibility, source control etc.

Create a Build Pipeline

I have created a sample .net core app and its running on my machine. Now I want to set up a CI-CD pipeline for this application using Azure DevOps. Please select build option from pipeline menu to set up build pipeline.

Now choose a build template provided by Azure DevOps as shown below.

I can also select the TFVC version control system or GitHub if I want to as source code. Now give a name to build definition. Please select an appropriate solution file to build & location to save build artifacts. These artifacts will be used as input to release pipeline. You can see which artifacts. Azure DevOps provides multiple predefined templates to build application developed in java, node.js, Php etc.



Create a Release Pipeline
Now once build succeeded, we need to create release definition. You can select release menu from the pipeline or click on the release button as shown below. When you get into the release pipeline screen, you’ll need to select a template.

Azure DevOps has provided a lot of predefined templates for deployment. Some of them are as follows
Azure App Service Deployment with Test and without Test
Azure App Service Deployment with continuous monitoring
Cloud Service Deployment
On-Premise deployment
Azure VM Scale Set
Service Fabric (Stateful/ stateless)
Azure Policy deployment
Function App to Azure
We can create our own custom template as well as per our requirement.

After selecting the template, we can add task so that we can deploy a build multiple environments like dev, test, UAT etc. We can add particular use as a release approver as well. We can set the variable values which are used in the release definition. You can convert those templates to YAML in a later stage as well and then check in version control if you want. You see that there are all kinds of pre-defined templates to do your builds. So for example, a Gradle build or a Go build, or you want to do some load testing, or you want to do Xamarin app for iOS, Ant builds, you name it; it's all there and part of the out-of-the-box experience. Azure DevOps has things like NuGet restore, Test Assemblies, Build the solution, all kinds of things that we can pick from the task picker.

After saving the release definition, you can create a new release. You can choose environments for release if you have added multiple release tasks.

After creating a release, we can track release progress as shown below.

We can enable pre-deployment approvals as shown below. Now, what happens when I did a deployment and the deployment failed? Well, I can select to re-deploy the previous well-known stable deployment so I'm always in a good state again, which is quite handy. So that's a way we can define those post approvals before we move to the next phase in our deployment.

Pipeline History
We can also look at the history where we can track the changes that are made to the release definition, which is also very handy if it comes to compliance and security. Now we can clone those different environments, because after and you want to do the same in let's say dev, as in staging as in test or production. We have different triggers here and one of the triggers is that we wanted to have continuous integration. So every time, changes in our Git repo, I want to trigger build/Release pipeline. We can also schedule things in Azure DevOps.

After successful completion of a release pipeline, you can visit the deployed version of your application.

Summary
Azure Pipeline is a cloud-hosted pipeline for fast CI/CD that works with any language, platform, and cloud. By connecting to any source control like GitHub, this service can release changes continuously to any cloud. YAML files are very useful in writing build and release definitions. Azure Pipelines has components like build, release, library, task groups, deployment groups. Azure Pipelines has advance workflows with native container support and features which allow monitoring CI/CD stages.
Take our free skill tests to evaluate your skill!

In less than 5 minutes, with our skill test, you can identify your knowledge gaps and strengths.