Implementing CI/CD pipeline on Azure
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.
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.
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).
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. Package Formats — To produce packages that can be consumed by others, you can publish NuGet, npm, or Maven packages to the built-in package management repository in Azure Pipelines. You also can use any other package management repository of your choice.
5. Pricing — It is free for public projects. But, for private projects, you can run up to 1800 minutes of pipeline jobs free per month.
Why should I use Azure Pipelines?
Implementing CI and CD pipelines help to ensure consistent and quality code that’s readily available to users. And, Azure Pipelines provides a quick, easy, and safe way to automate building your projects and making them available to users.
Use Azure Pipelines because it supports the following scenarios:
● Works with any language or platform
● Deploys to different types of targets at the same time
● Integrates with Azure deployments
● Builds on Windows, Linux, or Mac machines
● Integrates with GitHub
● Works with open-source projects.
Creating Azure Organizations
To create an Azure organization, Search for devOps and choose Azure DevOps organizations.
Click My azure devOps organizations.
To create new, Click Create new Organization
Provide a name for the Organization and the region where the projects under the Organizations will be hosted.
Creating Azure Projects
Once the Organization is created, You will be asked to create a project under an Organization.
Choose the project to be private and click Create project
CICD Pipeline using Azure DevOps Starter
Azure DevOps Starter creates a CI/CD pipeline in Azure Pipelines. You can create a new Azure DevOps organization or use an existing organization.
Azure DevOps Starter also creates Azure resources in the Azure subscription of your choice.
Azure DevOps Starter presents a simplified process for creating a continuous integration (CI) and continuous delivery (CD) pipeline to Azure. You can bring your existing code and Git repo, or you can select a sample application.
● Use DevOps Starter to create a CI/CD pipeline
● Configure access to your GitHub repo and choose a framework
● Configure Azure DevOps and an Azure subscription
● Commit changes to GitHub and automatically deploy them to Azure
● Examine the Azure Pipelines CI/CD pipeline
● Clean up resources
● An Azure subscription. You can get one free through Visual Studio Dev Essentials.
● Access to a GitHub or external Git repo that contains .NET, Java, PHP, Node.js, Python, or static web code.
Sign In to the Azure Portal
Search for DevOps starter
and click Create DevOps starter
Choose the application of your choice, For this tutorial, I will choose .NET
Click Next: Framework and then choose ASP.NET
Next: Service, Choose Windows Web App and Next: Create
Click Authorize to Access the GitHub account to create the workflow.
Once Authorized, You will be asked to choose the organization and the project and the Subscription where the Azure DevOps pipeline will be created.
Click Review + Create, It will start the Deployment process.
The Azure DevOps CI/CD Project is created, the Azure resources pane will take some minutes to load.
Now you can work with the team and make the required changes to the .NET apps with the automated CICD process that deploys the latest changes to the website.
On the right pane of Azure resources, click on the Browse button to view the application.
Cleaning up Resources
When you no longer need Azure App Service and the related resources that you created in this tutorial, you can delete them.
Use the Delete functionality on the DevOps Projects dashboard.