How to Add Environment Approvals and Gates in Azure Pipelines
Azure environments add approval checks and automated gates that a deployment job must clear before it runs.
Target an environment: from a deployment job. Configure approvals and gates on that environment in the UI; the job pauses until checks pass.
A deployment job targeting an environment
The environment "production" can carry a required-approvers check configured in Pipelines > Environments.
azure-pipelines.yml
stages:
- stage: Deploy
jobs:
- deployment: DeployProd
environment: production
strategy:
runOnce:
deploy:
steps:
- script: ./deploy.sh productionGotchas
- Approvals and gates are configured on the environment in the UI, not in YAML - the YAML only references the environment.
- A
deploymentjob (not a plainjob) is required to bind to an environment and trigger its checks. - Gates can poll external systems (e.g. a monitoring query) and delay until healthy.
Related guides
How to Create a Multi-Stage Pipeline in Azure PipelinesBuild a build-test-deploy multi-stage pipeline in Azure Pipelines with dependsOn chaining and condition so de…
How to Deploy to an Azure Web App from Azure PipelinesDeploy a build to an Azure Web App from Azure Pipelines with AzureWebApp@1 - a service connection, the app na…