Step-by-Step Guide to Setting Up Automated Deployment Pipelines Using Azure DevOps for .NET Applications
March 25, 2025 • 3 min read

If you're building .NET applications and want to streamline your release process, Azure DevOps offers a powerful and flexible way to automate builds, tests, and deployments through its CI/CD pipelines. In this guide, I’ll walk you through setting up a complete automated deployment pipeline using Azure DevOps for a .NET web application.
🧰 Prerequisites
Before we begin, make sure you have:
- An Azure DevOps account (sign up here)
- A Git repository with your .NET application (ASP.NET Web API, MVC, Razor Pages, etc.)
- An Azure subscription (for deployment)
- A basic understanding of Git and .NET CLI
🏗️ Step 1: Create a New Azure DevOps Project
- Go to dev.azure.com
- Click on New Project
- Give it a name and set visibility (private/public)
- Click Create
📁 Step 2: Push Your .NET Code to Azure Repos
If your code isn’t in Azure Repos yet:
git remote add origin https://dev.azure.com/{organization}/{project}/_git/{repo-name}
git push -u origin mainAlternatively, import your GitHub repo directly from Azure DevOps.
⚙️ Step 3: Create a CI Pipeline (Build)
In Azure DevOps, go to Pipelines > Create Pipeline
Select your code repository
Choose YAML for pipeline configuration
Use the following starter YAML for a .NET Core app:
# azure-pipelines.yml
trigger:
branches:
include:
- main
pool:
vmImage: 'windows-latest'
variables:
buildConfiguration: 'Release'
steps:
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '8.x.x' # Adjust based on your .NET version
- script: dotnet build --configuration $(buildConfiguration)
displayName: 'Build project'
- script: dotnet test --no-build --configuration $(buildConfiguration)
displayName: 'Run tests'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'Commit and run the pipeline — this builds and tests your code on every push to main.
🚚 Step 4: Set Up the Release Pipeline (CD)
- Go to Pipelines > Releases
- Click New Pipeline
- Choose Empty Job
- Add an Artifact:
- Select the build pipeline from earlier
- Choose the latest version
- Add a Stage (e.g., "Dev Deployment")
- In the stage, click Add Task > Azure App Service Deploy
- Choose your Azure subscription
- Select your App Service
- Configure the package path to the artifact
- Save and create a Release
- (Optional) Enable continuous deployment trigger so the release runs after every successful build.
🔐Step 5: Secure Secrets with Azure Key Vault
- To avoid storing secrets in pipelines:
- Create an Azure Key Vault
- Add secrets (e.g., connection strings, API keys)
- In the pipeline, add the Azure Key Vault task
5.Reference secrets in your code via environment variables
✅** Step 6: Test the Pipeline**
1.Push a change to main
2.Watch the CI pipeline run: it should build and test your app
3.If successful, the CD pipeline should deploy it automatically to Azure
🧼 Bonus Tips
Set up deployment slots for staging and production environments
Add approval gates for production releases
Use pipeline templates for reuse across multiple services
Add notifications via Teams or email
📦 Final Thoughts****
Automating your build and deployment processes improves developer productivity, reduces human error, and enables faster releases. Azure DevOps makes it relatively painless to set up robust CI/CD pipelines for .NET applications, and this setup scales well as your project grows.
Got questions or want to see advanced scenarios like container deployment or infrastructure-as-code pipelines? Drop a comment or reach out!
Happy shipping! 🚀
