Build and Release Pipelines in Azure DevOps
Introduction
Azure Pipelines automates build, test, and deployment of your applications to any platform. This tutorial guides you through creating a CI/CD pipeline using YAML, adding stages, and integrating with popular services.
Prerequisites
- An Azure DevOps organization – dev.azure.com
- Basic knowledge of Git
- Access to a repository (Azure Repos or GitHub)
Step 1 – Create a New Pipeline
- Navigate to Pipelines → New pipeline in your Azure DevOps project.
- Select the source repository (e.g., Azure Repos Git).
- Choose YAML as the configuration method.
The wizard will generate a starter azure-pipelines.yml file.
Sample YAML Pipeline
trigger:
- main
pool:
vmImage: 'ubuntu-latest'
variables:
buildConfiguration: 'Release'
stages:
- stage: Build
jobs:
- job: BuildJob
steps:
- task: DotNetCoreCLI@2
inputs:
command: 'restore'
projects: '**/*.csproj'
- task: DotNetCoreCLI@2
inputs:
command: 'build'
arguments: '--configuration $(buildConfiguration)'
projects: '**/*.csproj'
- task: DotNetCoreCLI@2
inputs:
command: 'publish'
arguments: '--configuration $(buildConfiguration) --output $(Build.ArtifactStagingDirectory)'
projects: '**/*.csproj'
- stage: Release
dependsOn: Build
jobs:
- deployment: DeployJob
environment: 'Production'
strategy:
runOnce:
deploy:
steps:
- download: current
artifact: drop
- task: AzureWebApp@1
inputs:
azureSubscription: ''
appName: ''
package: '$(System.DefaultWorkingDirectory)/**/*.zip'
Next Steps
- Add unit tests using the
dotnet testtask. - Secure secrets with pipeline variables and variable groups.
- Configure branch policies to enforce CI runs before merges.
- Enable continuous deployment to Azure Kubernetes Service (AKS) with Helm charts.