AZ

Azure Pipelines Deployment

Environment approvals, deployment strategies, and release management

Details

Language / Topic
azure-devopsAzure DevOps Pipelines
Category
Deployment

Rules

balanced
- Use deployment jobs (jobs: - deployment:) with environment: to track deployments and enable approval gates
- Configure environment approvals and checks: required reviewers, business hours, branch control for production
- Use the runOnce strategy for simple deployments; rolling for zero-downtime updates; canary for risk mitigation
- Deploy artifacts built in a prior stage — never rebuild in the deployment stage
- Tag releases with deployment metadata: environment name, build number, commit SHA for full traceability
- Deployment jobs: use deployment: keyword with environment: to get deployment history, approval gates, and tracking
- Environment checks: approvals (required reviewers), business hours, exclusive lock, branch control on production
- runOnce strategy: preDeploy → deploy → routeTraffic → postRouteTraffic → on:success/failure lifecycle hooks
- rolling strategy: deploy to a percentage of targets incrementally; set maxParallel to control rollout speed
- canary strategy: deploy to a small subset first, validate health, then proceed to full deployment
- Download artifacts from build stage: DownloadPipelineArtifact@2 with source: current and artifact: drop
- Multi-environment pipeline: Build → Deploy Dev (auto) → Deploy Staging (auto) → Deploy Prod (approval required)
- Use exclusive lock check on production environment to prevent concurrent deployments causing conflicts
- Health checks: add verification steps in postRouteTraffic hook — invoke smoke tests or health endpoint checks
- Rollback: use on:failure hook to trigger automatic rollback scripts or swap deployment slots
- Tag Git commits on successful production deploy: Git tag with version, environment, and timestamp
- Variable templates per environment: vars-dev.yml, vars-staging.yml, vars-prod.yml swapped per deployment stage