Introduction
In the realm of collaborative development, Continuous Integration (CI) and Continuous Delivery (CD) play pivotal roles in streamlining workflows. By automating build processes and seamlessly deploying artifacts, developers can enjoy a faster and more reliable development lifecycle. In this guide, we’ll walk through the steps of setting up CI/CD using Azure DevOps for a .NET Core API, ensuring a smooth integration and delivery process.
Prerequisites
1.Azure Subscription
2.Azure DevOps Organization
3.Azure Project and Repo
Continuous Integration: When multiple developers work on shared repository code and whenever changes are made, build process is automated in this approach. This helps in faster development lifecycle with less error.
Continuous Delivery: On continuous build, artifacts are collected from the build and is automatically published in the cloud in this approach.
Let’s follow the below steps to perform continuous build.
Consider a sample NET core API in the Azure repos. In this sample we will be creating build pipeline using classic editor.
Continuous Integration
- Navigate to the Organization-> Relevant Project -> Pipelines -> New Pipeline-> Use the classic Editor.
- Build Pipeline name: Kronos-ASP.NET Core (.NET Framework) – CI
- In the classic editor, choose the Repository and branch for which build has to be automated and choose “Empty Job.”
- Click “+” to add tasks to be performed in the build.
Add task -> .NET Core and give command as “restore”.
Add task -> .NET Core and give command as “build”.
Add task -> .NET Core and give command as “publish”,
Add task ->Publish Artifact
Choose the artifact name – “buildKronos“
5. For continuous build, Choose trigger tab and check “Enable continuous integration”.
6. Under Branch filter, we can choose for the branch on which build has to be automated. Whenever changes have been made on chosen branch, build pipeline will be triggered.
Once everything is set, we can manually trigger the run pipeline or whenever changes have been made to chosen branch, build pipeline will be triggered.
Continuous Delivery (CD):
- Navigate to Organization-> Project-> Pipeline-> Releases-> New Release pipeline-> Empty Job.
- Under Artifacts, select the build pipeline for which deployment has to be automated (e.g., Kronos-ASP.NET Core (.NET Framework)-CI).
3. Enable continuous deployment trigger for automatic deployment upon a successful build.
4. In Stages, add a task for deploying to Azure App Service, choosing the subscription and app service name.
Once everything is set, we can manually create a release if already build pipeline artifact is present or whenever build pipeline is successfully completed, Release pipeline will be triggered.
Hope this blog helps in CI/CD implementation.
No Comment! Be the first one.