Azure DevOps Pipelines Tutorial: CI/CD from Scratch (2026)
The first time I set up a CI/CD pipeline, I manually SSH'd into servers and ran deployment scripts. After one too many late-night deployment failures, I switched to Azure DevOps Pipelines. Now every commit triggers automated builds, tests, and deployments. The confidence of knowing every change is validated and deployable is invaluable.
Azure DevOps Pipelines is a cloud-based CI/CD service that builds, tests, and deploys applications to any platform. Define pipelines as YAML code in your repository — version-controlled, reviewable, and repeatable. Supports Windows, Linux, macOS, containers, and virtually any language or framework.
YAML Pipeline Fundamentals
Pipeline as code using azure-pipelines.yml. Define triggers (CI on branches, PRs), pool (VM image), and steps (tasks). Variables customize behavior. Templates share common steps across pipelines.
trigger:
branches:
include:
- main
- develop
pool:
vmImage: ubuntu-latest
steps:
- task: DotNetCoreCLI@2
inputs:
command: build
projects: "**/*.csproj"
Building and Testing with Multi-Stage Pipelines
Multi-stage pipelines organize build, test, and deploy stages. Run unit tests, collect code coverage, publish test results. Conditionally run stages based on branch or parameter. Approvals gate production deployments.
stages:
- stage: Build
jobs:
- job: BuildJob
steps:
- task: DotNetCoreCLI@2
inputs: {command: test, arguments: "--configuration Release"}
- task: PublishTestResults@2
inputs: {testResultsFormat: VSTest, testResultsFiles: "**/*.trx"}
Container Builds and Docker Integration
Build and push container images to Azure Container Registry or Docker Hub. Use Docker tasks or script steps. Kubernetes manifest deployment in later stages. Multi-architecture builds for cross-platform images.
- task: Docker@2
inputs:
containerRegistry: acr-service-connection
repository: myapp
command: buildAndPush
Dockerfile: "**/Dockerfile"
tags: |
$(Build.BuildId)
latest
Release Gates and Approvals
Environment-based approvals require manual sign-off before deployment. Gates evaluate health metrics before promotion — monitor failure rate, query work items, or check Azure Monitor alerts. Pre-deployment and post-deployment conditions.
- stage: DeployProduction
dependsOn: DeployStaging
condition: succeeded()
jobs:
- deployment: Production
environment: production
strategy:
runOnce:
preDeploy:
steps:
- script: echo "Approved. Deploying..."
Variable Groups, Library, and Secure Files
Variable groups store common config across pipelines. Azure Key Vault integration syncs secrets. Library contains secure files (certificates, provisioning profiles). Variable group linking by name.
- task: AzureKeyVault@2
inputs:
connectedServiceName: kv-service-connection
keyVaultName: my-pipeline-vault
secretsFilter: "*"
- task: DotNetCoreCLI@2
inputs:
command: build
arguments: '--configuration Release /p:Version=$(Build.BuildNumber)'
Self-Hosted Agents and Scaling
Microsoft-hosted agents have pre-installed tools. Self-hosted agents on your VMs give full control. Agent pools organize agents by capability. Scale set agents auto-scale in Azure VMSS. Run agents in containers or Kubernetes.
# Install agent on Windows:
./config.cmd --unattended --url https://dev.azure.com/org --auth pat --token $(PAT) --pool MyPool --agent my-agent
# Docker agent:
docker run -e AZP_URL=https://dev.azure.com/org -e AZP_TOKEN=$(PAT) -e AZP_POOL=MyPool mcr.microsoft.com/azure-pipelines/vsts-agent:ubuntu-latest
Frequently Asked Questions
What is the difference between Azure Pipelines and GitHub Actions?
Both provide CI/CD. Azure Pipelines offers deep Azure integration, self-hosted agents, and enterprise features. GitHub Actions has tighter GitHub integration and a larger community marketplace.
Can I use Azure Pipelines with non-Microsoft technologies?
Yes. Supports Node.js, Python, Java, Go, Ruby, C++, Android, iOS, and any language via script tasks or community tasks.
How do I handle secrets in pipeline variables?
Mark variables as secret in the pipeline UI or YAML. Use Azure Key Vault integration. Secrets are masked in logs and never exposed in output.
What are pipeline caching and artifact staging?
Pipeline caching speeds up builds by restoring dependencies. Artifact staging publishes build outputs for use in later stages or releases.
Originally published on Ayodhyyya. Last updated June 1, 2026.