Deployment automation is a set of capabilities that drive higher software delivery and organizational performance. Deployment automation enables you to deploy your Azure DevOps software to testing and production environments with the push of a button. Automation is essential to reduce the risk of production deployments. It’s also necessary to provide fast feedback on the quality of your software by allowing teams to do comprehensive testing as soon as possible after changes.
What is CI/CD Pipeline:
Deployment automation can be achieved with the help of CI\CD pipelines. CI/CD is a method to frequently deliver apps to customers by introducing automation into the stages of app development. The main concepts attributed to CI/CD are continuous integration, continuous delivery, and continuous deployment. Continuous integration/continuous deployment (CI/CD) pipelines can help you quickly build, test, and deploy high-quality applications. CI/CD is a solution to the problems integrating new code can cause for development and operations teams.
Below is a representation of a CI/CD pipeline setup and how it works.
Stages of a CI/CD Pipeline:
- 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.
- 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. That can also be facilitated in this stage if docker images are to be constructed. Failing this stage marks a potential error in the code or its dependencies.
- 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.
- 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 primary stages, and different steps can be added to make the CI/CD process more automated. We have Azure DevOps CI/ CD to bring a new life to these stages.
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. Some of the benefits are:
- Azure Repos provides Git repositories or Team Foundation Version Control (TFVC) for source control of your code.
- Pipelines provide builds and release services to support continuous integration and delivery of your applications.
- Azure Boards delivers a suite of Agile tools to support planning and tracking work, code defects, and issues using Kanban and Scrum methods.
- Test Plans provides several tools to test your apps, including manual/exploratory testing and continuous testing.
- Azure Artifacts allows teams to share Maven, npm, NuGet, and more packages from public and private sources and integrate package sharing into your pipelines.
These resources are quite helpful, especially Azure Pipelines. In this article, we will be using Azure Pipelines to create a CI/CD pipeline for a .NET project.
What are 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.
Azure DevOps Architecture:
This is how Azure DevOps works:
1: The developer changes the application source code.
2: The developer updates the application code containing the ‘web .config’ file to the source code repository in Azure Repos.
3: Afterwards, Continuous integration triggers the application to build and unit tests using Azure Test Plans.
4: Continuous deployment within Azure Pipelines triggers an automated deployment of application artifacts with environment-specific configuration values.
5: The developer then deploys the artifacts to the Azure App Service. Further, Azure Application Insights collects and analyzes health, performance, and usage data.
6: Developers monitor and manage health, performance, and usage information.
7: Azure uses backlog information to prioritize new features and bug fixes by employing Azure Boards.
Integrating Azure DevOps with different tools:
Azure DevOps has robust integrations with Azure and a comprehensive suite of technologies that help you deliver DevOps software securely and quickly. It provides integration with popular open-source and third-party tools and services across the entire DevOps workflow. It helps spend less time integrating and more time delivering higher-quality software faster.
- Creating a build pipeline for ASP.net app with source code in Git hub.
- Deploy this app on the already created Azure app service
Creating A build Pipeline in Azure DevOps:
First, navigate to your team project on Azure DevOps in a new browser tab. Navigate to Pipelines.
Click New pipeline. We will use the wizard to automatically create the YAML definition based on our project.
Select the GitHub as the source hosting platform as the code is in Git Hub Repo
Afterwards, click on the required repo.
Select the ASP.NET template as the starting point for your pipeline.
Also, add a “Publish Build Artifact” at the end of the YAML file.
Review the contents of the YAML definition. The system will save it as a new file called “azure-pipe in the repository’s root and contain everything needed to build and test a typical ASP.NET solution. You can also customize the build as required. In this case, update the pool to specify the build should use a Visual Studio 2017 build VM. Review trigger and point to master if your repo does not have main (new repos will have “main” instead of “master”).
Click Save and run.
Click Save and run to confirm the commit.
Track the build until it completes. Click Job to see the logs.
Deploying App to Azure App Service using Azure Deploy Pipeline:
Navigate to Release in Pipelines.
Select New and then New release pipeline.
For Stage 1, select Azure App Service Deployment.
Provide required details for the stage.
In Add an Artifact, provide your required artifact.
Finally, select Create a release, and it will deploy the artifact to the Azure app service.
In a nutshell, Azure DevOps is a robust, agile tool that focuses on combining planning and tracking with developer and DevOps tool for developing and deploying code to your server. It supports a friendly GUI and efficient integration. Therefore, thanks to Azure DevOps, we can now ensure solutions from product development to product delivery much faster. So, you must implement it in your organization.