How to Implement Manual Approvals Before Production Deployment?

kiran hiremath_DEV 40 Reputation points
2026-11-18T09:44:01.56+00:00

We are using Azure DevOps YAML pipelines to build and deploy an application across multiple environments, such as Development, QA, UAT, and Production.

Currently, we want to automate deployments to Development and QA environments. However, deployments to UAT and Production should happen only after approval from the respective environment owners.

I am trying to understand the recommended way to implement this using Azure DevOps multi-stage YAML pipelines.

I have a few questions:

Can we configure manual approvals directly in a YAML pipeline, or should we use Azure DevOps Environments?

How can we ensure that the Production deployment starts only after successful completion of the UAT stage?

Can different teams or users be assigned as approvers for different environments?

Is it possible to prevent the pipeline author from bypassing the approval process?

What happens if an approval is rejected or times out?

If possible, could someone share a sample multi-stage YAML pipeline demonstrating this implementation and explain the recommended approach for a production environment?

Azure DevOps
0 comments No comments

Answer accepted by question author
Anurag Rajkumar Rohikar 3,190 Reputation points Microsoft External Staff Moderator
2026-11-18T10:20:41.26+00:00

The recommended approach is to use Azure DevOps Environments with Approvals and Checks rather than implementing approval logic entirely within the YAML pipeline.

Azure DevOps provides environment-level approval controls that are managed outside the YAML file. This is particularly useful because pipeline authors cannot simply remove these checks by modifying their YAML definition.

Step 1: Create Azure DevOps Environments

Navigate to:

Pipelines → Environments → New Environment

Create the following environments:

Development

QA

UAT

Production

These environments provide deployment history, resource tracking, and deployment control.

Step 2: Configure approval checks

For UAT and Production:

Open the respective environment.

  1. Navigate to Approvals and checks.

Select Approvals.

Add the required approvers or groups.

Configure the approval timeout and other required settings.

Save the configuration.

For example:

UAT: QA Lead or Testing Team.

Production: Release Manager or Production Support Team.

Approvals are configured outside the YAML pipeline, which provides an additional security boundary.

Step 3: Implement a multi-stage YAML pipeline

Below is an example:

trigger:
- main

pool:
  vmImage: ubuntu-latest

stages:

- stage: Build
  displayName: Build Application
  jobs:
  - job: BuildJob
    steps:
    - script: echo "Building application..."
      displayName: Build

- stage: Development
  displayName: Deploy to Development
  dependsOn: Build
  jobs:
  - deployment: DeployDev
    environment: Development
    strategy:
      runOnce:
        deploy:
          steps:
          - script: echo "Deploying to Development"

- stage: QA
  displayName: Deploy to QA
  dependsOn: Development
  jobs:
  - deployment: DeployQA
    environment: QA
    strategy:
      runOnce:
        deploy:
          steps:
          - script: echo "Deploying to QA"

- stage: UAT
  displayName: Deploy to UAT
  dependsOn: QA
  jobs:
  - deployment: DeployUAT
    environment: UAT
    strategy:
      runOnce:
        deploy:
          steps:
          - script: echo "Deploying to UAT"

- stage: Production
  displayName: Deploy to Production
  dependsOn: UAT
  condition: succeeded()
  jobs:
  - deployment: DeployProduction
    environment: Production
    strategy:
      runOnce:
        deploy:
          steps:
          - script: echo "Deploying to Production"

Note: This is a simplified example demonstrating deployment sequencing. Replace the echo commands with actual deployment tasks for your application.

Step 4: Understand how the approval process works

When the pipeline reaches the UAT stage, Azure DevOps evaluates the approval checks configured on the UAT environment.

If approved, the UAT deployment proceeds.

If rejected, the stage does not proceed.

If the approval times out, the stage fails according to the configured timeout behavior.

The Production stage starts only after UAT completes successfully and the Production environment's approval checks are satisfied.

Step 5: Prevent approval bypass

For production environments, consider the following security measures:

Configure approvals and checks directly on the Production environment.

Restrict environment administrator permissions to trusted administrators.

Avoid granting unnecessary permissions to pipeline contributors.

Use dedicated security groups for approvers.

Restrict who can administer or modify approval checks.

Use branch control checks to ensure deployments originate from approved branches.

Remember that environment-level checks are managed outside the YAML definition, but users with sufficient administrative permissions can still modify them. Restrict those permissions appropriately.

Official Microsoft documentation

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

Answer accepted by question author

AI answer

2026-11-18T09:45:46.0866667+00:00

Use separate Azure DevOps Environments for UAT and Production, configure their approvals in the Azure DevOps UI, and reference each environment from a YAML deployment job.

Approvals and checks are deliberately stored outside YAML, so changing the pipeline file cannot remove them. Resource owners control when a pipeline may consume the protected environment. ^1^

Configure the environments and approvals

  1. Go to Pipelines → Environments → Create environment.
  2. Create Development, QA, UAT, and Production.
  3. Open UAT → Approvals and checks → + → Approvals.
  4. Add the UAT-owner user or group, disable self-approval if required, set the timeout, and select Create.
  5. Repeat for Production, assigning the production-owner group.
  6. Under each environment's Security → Pipeline permissions, select Restrict permission and authorize only the intended pipeline.

Different users or groups can therefore approve UAT and Production. If a group is an approver, one member of that group is sufficient unless the approval configuration imposes another requirement. The approver list is fixed when that check begins, so later membership/configuration changes do not affect the pending check. ^1^

Environments also provide deployment history and control which users and pipelines may target them. ^2^

Example multi-stage pipeline

The approval is not represented in this YAML. It is automatically evaluated when the UAT or Production deployment job requests its corresponding environment.

trigger:
- main

pool:
  vmImage: ubuntu-latest

stages:
- stage: Development
  jobs:
  - deployment: DeployDev
    environment: Development
    strategy:
      runOnce:
        deploy:
          steps:
          - script: echo "Deploy to Development"

- stage: QA
  dependsOn: Development
  condition: succeeded()
  jobs:
  - deployment: DeployQA
    environment: QA
    strategy:
      runOnce:
        deploy:
          steps:
          - script: echo "Deploy to QA"

- stage: UAT
  dependsOn: QA
  condition: succeeded()
  jobs:
  - deployment: DeployUAT
    environment: UAT
    strategy:
      runOnce:
        deploy:
          steps:
          - script: echo "Deploy to UAT"

- stage: Production
  dependsOn: UAT
  condition: succeeded()
  jobs:
  - deployment: DeployProduction
    environment: Production
    strategy:
      runOnce:
        deploy:
          steps:
          - script: echo "Deploy to Production"

Replace the scripts with your artifact-download and deployment tasks. Deployment jobs are recommended for environment deployments and record deployment history against the referenced environment. ^3^

Production explicitly depends on UAT and uses condition: succeeded(). Consequently, it can request Production approval only after UAT deployment and its approval have succeeded. The success condition is normally implicit, but keeping it explicit makes the release requirement clear. ^4^

If adding a branch restriction, preserve the dependency-success check:

condition: and(
  succeeded(),
  eq(variables['Build.SourceBranch'], 'refs/heads/main')
)

A custom condition replaces the default condition, so omitting succeeded() could allow unexpected execution after an earlier outcome. ^5^

Preventing approval bypass

Separating the approval from YAML prevents an ordinary pipeline author from deleting it through a code change, but permissions must also be separated:

  • Transfer environment governance to a release/platform-owner group. The environment creator is initially an Administrator.
  • Ensure pipeline authors have no direct or inherited environment role or permission that allows managing approvals and checks. The environment documentation lists Creator, Administrator, and User—but not Reader—as roles that can manage checks.
  • Restrict environment pipeline permissions to specifically trusted pipelines rather than enabling open access.
  • Protect the production service connection separately if it represents the actual production credential; approvals and checks can also be applied to service connections.
  • Limit resource Administrator membership. A resource Administrator can deliberately select Bypass check, and the bypass is recorded in the checks panel. ^1^

Protected-resource permissions and pipeline permissions should grant access only to the users and pipelines that require it. ^6^

Rejection and timeout behavior

  • Rejected approval: the check terminally fails and the protected stage is not executed.
  • Approval timeout: the stage is marked skipped.
  • Stages depending on a timed-out/skipped stage are also skipped.
  • A stage can be retried after its approvals or checks time out. ^1^

Environment approval timeout does not automatically cancel the entire pipeline run. If the requirement is specifically to fail the validation path when nobody responds, a conditional alternative is an agentless ManualValidation@0 job with onTimeout: reject:

- job: ApproveProduction
  pool: server
  timeoutInMinutes: 1440
  steps:
  - task: ManualValidation@0
    timeoutInMinutes: 720
    inputs:
      notifyUsers: '[Email]'
      instructions: 'Review and approve the production release.'
      onTimeout: reject

Make the production deployment job depend on ApproveProduction. This causes the validation job to reject/fail on timeout; it should not be described as canceling the entire run. Because this validation is defined in editable YAML, retain protected environment approvals as the stronger production governance control. ^7^


References

  1. Define approvals and checks
  2. Create and target Azure DevOps environments
  3. Illustrates referencing output variables from a job in one stage to a deployment job in a subsequent stage, including usage in conditions and variables.
  4. Add stages, dependencies, and conditions
  5. Pipeline conditions
  6. Resource security
  7. How to reject the ADO pipeline execution, if approval doesn't provide - Microsoft Q&A
AI-generated content may be incorrect. Read our transparency notes for more information.

Was this answer helpful?

1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.