How To Build a CI/CD Pipeline In Azure DevOps ?

Harshit Paul

Posted On: February 2, 2021

view count176737 Views

Read time21 Min Read



Azure DevOps by Microsoft Azure is one of the leading tools that automate CI/CD’s process and, in turn, supports automatic builds and code projects to make them available to others. The Azure pipelines combine Continuous Integration (CI) and Continuous Delivery (CD) to consistently test and build the code and ship it to the target environment.

In this article, we will learn how to configure an Azure CI/CD pipeline and integrate it to LambdaTest Azure DevOps for bug tracking. LambdaTest is a cross browser testing cloud trusted by 500,000+ users that facilitates easy integration with numerous CI/CD tools to boost your go-to-market delivery.

You can accelerate your test cycles, trim down your overall test execution, and scale with ease by running Selenium tests in parallel from Azure pipelines on LambdaTest cloud.

What is a CI/CD Pipeline?

A CI/CD pipeline automates the continuous integration and deployment, streamlining software delivery through key stages like Build, Test, Merge, and Deploy. A DevOps pipeline is an automated system encompassing tools and practices used by development and operations teams to efficiently build, test, and deploy software. Key to modern software delivery, it streamlines the entire software development lifecycle (SDLC), emphasizing rapid, incremental updates and collaboration between teams for quicker and more reliable software releases.

In essence, a pipeline might seem complex, but it’s a time-saving, developer-friendly set of steps for efficient software version delivery.

Top 13 Benefits of CI/CD You Should Not Ignore

Stages of a CI/CD Pipeline:

  1. Source Stage – In most cases, when a change is attempted to the central repository, a pipeline run is triggered. These triggers are set by the CI/CD pipeline tool in the source stage.
  2. Build Stage – The combination of source code and its dependencies when building into a runnable instance corporate to the end-user application. The built-in application languages like Java need compilation too, which is done in the build stage. If docker images are to be constructed, that can also be facilitated in this stage. Failing this stage marks a potential error in the code or its dependencies.
  3. Test Stage – This stage corresponds to automated tests running to validate our code and its behavior accordingly. This stage acts as a sieve that prevents the bugs from reaching the end-user. There can be multiple stages, from smoke tests to end-to-end integration tests. Failure at this stage will expose errors in the code.
  4. Deploy Stage – Once we have a runnable code, the deployment is processed with all predefined tests passed. There are a lot of stages like “Beta,” “Staging,” etc., for the product team. A “Production” stage for the end-users is also present.

Remember, the stages mentioned above are the basic stages, and different steps can be added to make the CI/CD process more automated. To bring a new life to these stages, we have Azure DevOps CI/CD.

Here are the Top 10 CI/CD Pipeline Implementation Challenges And Solutions.

What is Azure DevOps?

Azure DevOps is a collection of services given by Microsoft Azure. It provides development services for a team to support, plan, collaborate, build, and deploy applications. It provides integrated features in a browser or an IDE(Integrated Development Environment). Some of the services for developers are :

  • Azure Repos
  • Azure Pipelines
  • Azure Boards
  • Azure Test Plans
  • Azure Artifacts

These resources are quite useful, especially Azure Pipelines. In this article, we will be using Azure Pipelines to create a CI/CD pipeline for a .NET project.

We will also connect the Azure DevOps CI/CD to LambdaTest account at a later stage. This will help you push the bug, epic, task, story, etc., to the Azure DevOps project instance. And guess what! This is freemium.

What is Azure Pipelines?

The Azure CI/CD pipeline simplifies continuous integration and continuous delivery (CI/CD) in the application development process. You can start from the source stage with existing code on GitHub or on-premise containers. The Azure Repos can maintain a central repository, and the Azure pipelines maintain build and release pipelines for the given project. The Azure DevOps CI/CD process is a crucial process with all the required dev services.

Apart from continuous integration and continuous deployment with Azure DevOps, these pipelines are used to construct build-deploy-test workflows used mainly in continuous testing (CT). This tests the changes in a fast and scalable routine.

Advantages of Azure Pipelines:

The Azure Pipelines can be multifactored, and in the Azure DevOps CI/CD practice, they provide various advantages:

  1. Version Control Systems – Having the code into a version control system is the first step of building an Azure CI/CD pipeline. You can manage your source code in GitHub, Bitbucket, Subversion, or any other Git repository. It also supports Team Foundation Version Control (TFVC).
  2. Programming Languages and Application Types – You can use different languages with Azure pipelines like Java, Ruby, C, C++, Python, PHP, Go, and JavaScript.
  3. Deployment Targets – The applications with Azure CI/CD pipelines can be deployed to multiple target environments. This includes Virtual Machines, Containers, or any On-prem or Cloud Platform.
  4. Pricing – It is free for public projects. But, for private projects, you can run up to 1800 minutes of pipeline jobs free per month.

How to build Azure CI/CD Pipeline?

To create an Azure CI/CD Pipeline, you need to follow the below-given steps:

  1. Create an ASP.NET sample DevOps project using Azure DevOps Starter resource in Azure.
  2. Examine Azure CI/CD pipelines configured by Azure DevOps Starter.
  3. Clone the sample DevOps project to the system.
  4. Commit the code and execute CI/CD.

We will later attempt the LambdaTest Azure DevOps CI/CD integration to ease bug tracking, pushing the epic, story, or any task to the respective project anytime.

Prerequisites

  1. You will need an active Azure account for creating Azure Repos and Pipelines. You can create a Microsoft Azure Account for the same.
  2. For creating a sample app, we will be using Visual Studio and .NET Core. You can download Visual Studio and get .NET Core from the .NET Download Archives page.

Creating an ASP .NET DevOps Project using Azure DevOps Starter

Azure DevOps project simplifies the setup of CI/CD pipelines in Azure. You can go with the existing code or create a sample application as a new Azure DevOps project.

Here, we will create a new DevOps project by following the steps below:

  1. Sign in to your Azure account at the Microsoft Azure Portal.
  2. Select the + Create a Resource button under the Azure Services, and then search for DevOps Starter.
  3. azure devops

  4. Then choose the DevOps Starter and click on Create.
  5. devops starter

  6. Select .NET as shown in the below figure, and click Next.
  7. devops-starter

  8. The .NET sample application consists of either the Open – source ASP.NET framework or cross-platform ASP.NET Core framework. Go for the ASP.NET Core framework. You can also toggle over and select the Add a Database option if needed. When you’re done, choose Next.
  9. Add-a-Database

  10. You can deploy your application either to Windows Web App or Virtual Machine. The Windows Web App is the default deployment target, but you can choose a Virtual machine. Choose and click Next.
  11. Windows Web App

  12. On the next screen, provide the Project name, Azure DevOps Organization, Subscription, and Web app name (Web app name should be unique in Azure). You can change the location from the default, which is South Central US. Let’s go with the default for now.
  13. Azure DevOps Organization

  14. You can select the Additional settings if you want to change the web app or database parameters.
  15. Additional-settings

  16. When the settings are completed, choose Done.
  17. Once the deployment is done, select Go to resource to view it.
  18. pasted-image

  19. The Azure DevOps CI/CD Project is created, the Azure resources pane will take some minutes to load. The project also creates –
    • A team project with sample .NET code repository.
    • An Azure Web App and Azure SQL Database (if the database toggle was selected) in Azure.
    • Build Pipeline to compile and test the application.
    • Release Pipeline to deploy the application.
  20. Azure-DevOps-CI-CD

  21. You can now collaborate with your team on the ASP .NET Core App with an automated CI/CD process that deploys the latest change to the website.
  22. On the right pane of Azure resources, click on the Browse button to view the application.

Azure-resources

Perform Selenium automation testing from Azure Marketplace across 3000+ real browsers and OS!

Examining the CI/CD Pipeline of the Sample DevOps Project

When created, the project automatically configures a complete CI/CD Pipeline in your Azure DevOps organization. However, you can still do customization on these pipelines.

  1. On the top of the Azure Dashboard, there are options of both Build Pipelines and Release Pipelines. On clicking on any of the options, a new browser tab gets open up with the Pipeline.
  2. Sample-DevOps-Project

Build Pipelines :

  1. Click on the Build Pipelines on the Azure Dashboard.
  2. After the new browser tab opens up, select Edit from the top-right of the screen.
  3. Build-Pipelines

  4. You can see various tasks for your build pipeline. The build pipeline can do a number of tasks like fetching code from a repository, restoring dependencies, compiling applications, running tests, and giving outputs for deployments.
  5. build-pipeline

  6. Select the History tab under the name of the build pipeline. You will see an audit trail of all the changes for the build. Azure DevOps keeps track of all the changes made to the build specification and allows you to compare those via versions.
  7. history

  8. Select the Triggers tab, and you will see that the Azure DevOps CI/CD Project automatically created a trigger named CI trigger, that is on every commit to the repository will initiate a new build. You can include or exclude the branches as per your choices from the continuous integration process.
  9. CiCd Azzure

  10. Select Retention Tab to add, view, or delete the policies to keep or remove a certain number of builds.

Release Pipelines :

  1. Select Releases under the Pipelines section from the left side.
  2. The release pipeline manages the deployments in Azure DevOps. Click on Edit to examine the pipeline.
  3. Below the release pipeline’s name, you will find the same tabs as in the build pipeline.
  4. Under the Pipeline tab, go to the Artifacts, and select Drop. The build pipeline we examined before is the output to the Artifact.
  5. Artifacts

  6. The release pipeline has an enabled Continuous deployment trigger. This executes a deployment every time a new build takes place. You can also disable the trigger, where the deployments will require manual execution.
  7. Select the dev stage and then click on the Tasks tab at the top. The tasks define all the activities your deployment performs. Like you can see in the below figure.
  8. Tasks-tab

  9. The five tasks done are attempted on the agent. These can be foreseen as –
    • Azure Resources Deployment – This deploys all the Azure resources like Azure Web App and Azure SQL Database for application usage.
    • Azure App Service Deploy – This deploys the application package to a website.
    • Azure SQL Database Deployment – The SQL changes are deployed to the database.
    • Visual Studio Tests – This runs functional tests after deployment.
  10. On the left pane, you will find Releases under Pipelines. This shows the history of releases.
  11. Releases-under-Pipelines

  12. Select the release number to view the release summary. There are menus to explore, like associated work items, release summary, and tests.
  13. pasted-image

  14. Select Logs below dev. The logs will show all the useful information about the deployment. The logs can be viewed both during and after deployments.

Cloning the Sample DevOps Project Repository

  1. On the Azure Dashboard, click on the project’s name from the left pane. A new window opens up.
  2. On the new window, click on the Clone button from the top-right of the screen and copy the repository URL.
  3. Clone Repository Azure DevOps

  4. Open the Visual Studio on your system and click Continue without code on the right side, below the Get started menu.
  5. Click View ->Team Explorer option on the IDE, and also select Clone on the Explorer window.
  6. State the repository URL copied from your Azure Portal and specify the folder where you want your repository to get cloned on your system.
  7. Click Clone to start the cloning.
  8. Once the code is successfully cloned, you can view the whole project on the Solutions Explorer and make changes.

Note: As soon as you merge the changes to the remote repository, the build process gets triggered.

Commit the code and execute CI/CD

  1. The sample project we have created has a Git Repository in Azure DevOps Organization, which can be viewed in Azure Repos. The same repository has been cloned in Visual Studio 2019 via the previous steps.
  2. In the Visual Studio 2019 solutions explorer, navigate to Application/aspnet-core-dotnet-core/Pages/Index.cshtml file.
  3. Double-click the Index.cshtml to open it. Add a text line “This is a test message” in the division class “content – body.”
  4. Right-click on the solution in the Solution Explorer and then click Commit .. to check-in code.
  5. Give a comment as a commit reason, and then click on Comment All.
  6. Click Sync to synchronize the code changes with the server.
  7. Click Push to push the changes to the remote repository from the local repository.
  8. In your browser, navigate to Pipelines > Builds. Now there would be a build in progress. This build is triggered automatically due to a code change.
  9. As soon as the build is completed, Release takes place.
  10. Once the build and release are completed, hop on to the Azure DevOps Project Dashboard. On the right pane, click Browse to view the updated running application.
  11. Setting Up Azure DevOps Project

Integrating Azure DevOps With LambdaTest Account for bug tracking

Getting acquainted with continuous integration and continuous deployment with Azure DevOps was our goal, but what’s the whole point of learning it? What’s the purpose of it? The Azure CI/CD Pipeline, when integrated with LambdaTest, provides easy real time browser testing. This real time browser testing is quite useful for tracking the issues from LambdaTest and listing it on the Azure DevOps CI/CD Dashboard of the Project. To start with, let’s integrate LambdaTest with Azure DevOps :

  1. Login to LambdaTest Account.
  2. Go to Integrations and select Azure DevOps to integrate Azure DevOps with your LambdaTest account.
  3. After LambdaTest Azure DevOps CI/CD integration, go to the Real Time Testing option.
  4. Place your Project URL in the required URL field; to find the URL of the project, go to the Project details, and in the right pane, you will find a browse button. Right-click and copy the link address, and paste it to the URL field on the LambdaTest portal.
  5. CI CD Pipeline

  6. Select the VM (Virtual Machine) configuration; select the desired browser, browser version, OS, and resolution from the given options. For now, I am going with the default configuration.
  7. Real Time Testing

  8. Click on Start to launch the VM. You can see the webpage with the option to report bugs in it. You can also take a screenshot of the bug via the Bug icon on the left side.
  9. Mark as bug

  10. After the screenshot gets captured, you can add any issue to the task or issue with an inbuilt image editor. After highlighting a bug, you can report it through the button, Mark as Bug.
  11. Mark as bug in visual testing

  12. Once you click on Mark as Bug, you will get an option to provide all the details related to the bug.
  13. Mark as bug popup

  14. Click on Create Issue. Once you hit the button, you will get a prompt message at the top saying Bug Marked Successfully, and the bug will be pushed to the project.
  15. Go to the Azure DevOps project by logging in to your Azure Portal. Then, on the left pane under the Boards, head to the Work Items. You will see the issue there.
  16. Click on the title of the issue, and view all the data provided by LambdaTest. LambdaTest provides test environment details and screenshots in your work item on the respective project.
  17. This can be viewed with repro steps, System info, and all other details right on the Azure DevOps Portal.
  18. Azure DevOps Portal

  19. As you can view on the right side, you have Development and Deployment. Underneath Development, you can create a new branch or just send a pull request or commit the code after resolving the bug.
  20. Underneath Development

  21. Under Deployment, you can go to the release which has the associated bug and then view it.
  22. Deployment

Working on the Bug Reported by LambdaTest, by creating a new Branch

  1. On clicking on Create branch, under Development, give the branch’s name and select the bug reported from LambdaTest.
  2. Create branch in Azure DevOps Project

  3. You can now work on the bug by creating a new branch, and after resolving the bug, you can create a merge request.

Working on the Bug Reported by LambdaTest, by Commit/Pull Request

  1. When clicked on a commit/pull request, you have to specify the Link type, the Commit ID, and Comment.
  2. Bug Reporting

  3. Enter the Commit ID, and you can link it to that particular commit easefully. You can change the link type to Pull request and provide its ID. Then a Pull request will be generated.

These are the ways through which you can work with a bug reported via LambdaTest and resolve it. Assigning this bug to a developer or a team can also be done. This helps developers work in agile methodology.

Differences between CI/CD, Agile and DevOps

The Agile framework serves as a comprehensive umbrella encompassing multiple practices, including DevOps and CI/CD. While each practice operates at different levels, their ultimate goal remains consistent to produce superior software efficiently.

DevOps embodies an agile development practice and mindset, leveraging collaboration, communication, and appropriate tools to streamline the software development lifecycle, encompassing building, testing, and release processes.

CI/CD on the other hand, is a tactical approach within the DevOps framework. It employs automated testing tools to facilitate agile development principles, ensuring continuous integration and deployment.

Despite their nuanced distinctions, the three practices share a common objective: the creation of high-quality software within optimized timeframes. As a result, these practices often overlap, with familiarity in one invariably leading to familiarity in the others. Developers, quality assurance professionals, and operations personnel are likely to encounter and embrace all of these interconnected practices.

Conclusion

Kudos!! You have successfully integrated LambdaTest with Azure DevOps CI/CD Project and learned about configuring Pipeline with a sample ASP.NET Core Azure DevOps project. Begin your free ASP.NET testing.
Azure DevOps helps enterprises to plan smarter, collaborate faster, and ship better within the set of dev services. The automated Pipeline setup also provides the test, build, and deployment of the application in an easeful manner.

This is how you can actually use and configure the continuous integration and continuous deployment with Azure DevOps and Azure CI/CD Pipeline Architecture. This is a great tool to work with; Don’t worry; you will love to build Azure Projects or connect GIT to Azure DevOps.
Have a Happy Learning!!

Frequently Asked Questions

How do I make a CI CD pipeline in Azure?

Here are the high-level steps to create a CI/CD pipeline in Azure:

  1. Use DevOps Starter to start creating a CI/CD pipeline.
  2. Configure access to your GitHub repo and select a framework.
  3. Configure Azure DevOps, including taking an Azure subscription.
  4. Commit changes to GitHub and deploy to Azure.
  5. Check the Azure CI/CD pipelines.
  6. Clean the resources.

What is AWS CI CD pipeline?

AWS can help you automate your software delivery process, including initiating automatic builds and deploying to EC2 instances, using continuous integration and delivery (CI/CD) pipelines.

What is CI vs CD pipeline in Azure DevOps?

In Azure DevOps, Continuous Integration (CI) is a practice that encourages developers to integrate their code into a shared repository early and often. On the other hand, Continuous Deployment (CD) is a strategy that minimizes the time elapsed between writing a line of code and making that code available to users in production.

What is the difference between Jenkins and Azure Pipelines?

Jenkins is an open-source tool used for continuous integration and deployment. It’s self-hosted and requires setup and maintenance. Azure Pipelines, a cloud-based tool within Microsoft’s Azure DevOps services, offers hosted agents for CI/CD pipeline creation, reducing the need for infrastructure management.

How do I use pipeline in Azure DevOps?

You can use Azure DevOps pipelines by first creating a new pipeline through the Azure DevOps portal, then defining your pipeline in a YAML file or using the classic editor. You’ll need to connect your code repository, select a template (or define your steps manually), and then run the pipeline to build and deploy your code.

What is CI CD pipeline in Databricks?

A CI/CD pipeline in Databricks would involve continuously integrating code changes, running tests, and deploying the updated code to Databricks environments. This can help ensure code quality and facilitate rapid deployment of new features or bug fixes. It typically involves tools like Git for version control and Jenkins or Azure DevOps for the CI/CD pipeline.

Author Profile Author Profile Author Profile

Author’s Profile

Harshit Paul

Harshit works as a product growth specialist at LambdaTest. He is also an experienced IT professional, who loves to share his thoughts about the latest tech trends as an enthusiast tech blogger.

Blogs: 78



linkedintwitter

Test Your Web Or Mobile Apps On 3000+ Browsers

Signup for free