Introduction
In modern software development, delivering features quickly without breaking existing functionality is a key requirement. This is where CI/CD pipeline using Azure DevOps for .NET applications becomes essential.
CI/CD stands for Continuous Integration and Continuous Deployment. It automates the process of building, testing, and deploying applications so that developers can focus more on writing quality code instead of managing releases manually.
In this guide, we will walk through how to set up a CI/CD pipeline in Azure DevOps for a .NET application with a clear, structured approach and real-world understanding.
What is CI/CD?
CI/CD is a development practice that enables teams to integrate code changes frequently and deploy them reliably.
Continuous Integration (CI)
Continuous Integration ensures that whenever developers push code to the repository:
The application is automatically built
Unit tests are executed
Errors are detected early
Continuous Deployment (CD)
Continuous Deployment ensures that after a successful build:
The application is automatically deployed to a server or cloud
No manual intervention is required
This combination helps in faster and safer delivery of software.
Why Use Azure DevOps for CI/CD?
Azure DevOps is a powerful platform provided by Microsoft that supports complete DevOps lifecycle management.
Key Benefits
Integrated version control (Repos)
Build and release pipelines (Pipelines)
Work tracking (Boards)
Easy integration with .NET applications
It is widely used for CI/CD pipeline setup for ASP.NET Core applications.
Prerequisites
Before setting up the pipeline, ensure the following:
Azure DevOps account
.NET application (ASP.NET Core or Console App)
Source code pushed to Azure Repos or GitHub
Step 1: Create a Project in Azure DevOps
Log in to Azure DevOps
Click on "New Project"
Provide project name and visibility
Explanation
This project will contain:
Source code
Pipelines
Build and deployment configurations
Step 2: Push Code to Repository
Upload your .NET application code to:
Azure Repos OR
GitHub repository connected to Azure DevOps
Explanation
CI/CD pipelines are triggered based on code changes in the repository.
Step 3: Create a Build Pipeline (CI)
Go to Pipelines → Create Pipeline
Select repository source
Choose "YAML" configuration
Sample YAML for .NET Build
trigger:
- main
pool:
vmImage: 'windows-latest'
steps:
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '7.0.x'
- script: dotnet restore
displayName: 'Restore Dependencies'
- script: dotnet build --configuration Release
displayName: 'Build Project'
- script: dotnet test
displayName: 'Run Unit Tests'
Explanation
trigger: Runs pipeline on code push to main branchUseDotNet: Installs required .NET SDKrestore: Downloads dependenciesbuild: Compiles the applicationtest: Runs unit tests
This completes the Continuous Integration setup.
Step 4: Add Publish Step
- script: dotnet publish -c Release -o $(Build.ArtifactStagingDirectory)
displayName: 'Publish Application'
- task: PublishBuildArtifacts@1
inputs:
pathToPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: 'drop'
Explanation
publish: Prepares deployable outputPublishBuildArtifacts: Stores output for deployment stage
Step 5: Create Release Pipeline (CD)
Go to Releases → New Pipeline
Add artifact from build pipeline
Add deployment stage (e.g., Azure App Service)
Explanation
This stage handles deployment after build success.
Step 6: Configure Deployment
Example: Deploy to Azure App Service
Add Azure App Service task
Select subscription and app
Use artifact from build
Explanation
Pipeline automatically deploys latest build
No manual upload required
Step 7: Enable Continuous Deployment Trigger
Enable CD trigger in release pipeline
Explanation
Every successful build automatically triggers deployment.
Real-World Flow
Developer pushes code →
Pipeline builds application →
Tests run →
Artifacts generated →
Application deployed
This creates a fully automated DevOps workflow.
Best Practices for CI/CD in Azure DevOps
Keep Pipelines Simple
Avoid unnecessary complexity in initial setup.
Use Branch Policies
Require pull requests
Enforce code reviews
Add Unit Tests
Ensure code quality before deployment.
Secure Secrets
Use Azure Key Vault or pipeline variables.
Common Mistakes
Skipping Tests
Leads to unstable deployments.
Hardcoding Configuration
Makes pipelines less flexible.
No Monitoring After Deployment
Issues may go unnoticed.
Advantages of CI/CD Pipeline in .NET
Faster delivery cycles
Reduced manual errors
Improved code quality
Better collaboration among teams
Limitations
Initial setup effort
Requires understanding of DevOps tools
Misconfiguration can break deployments
Summary
Setting up a CI/CD pipeline using Azure DevOps for .NET applications enables teams to automate build, test, and deployment processes efficiently. By implementing Continuous Integration and Continuous Deployment, developers can ensure faster releases, improved reliability, and better software quality. Azure DevOps provides a robust platform that integrates seamlessly with ASP.NET Core applications, making it a preferred choice for modern DevOps workflows.

Join the conversation! Your thoughts help the community grow.