πŸ”’ Guided

Pre-launch preview. Authorised access only.

Incorrect code

Guided by A Guide to Cloud
Explore AB-900 AI-901
Guided AZ-400 Domain 3
Domain 3 β€” Module 7 of 13 54%
13 of 25 overall

AZ-400 Study Guide

Domain 1: Design and Implement Processes and Communications

  • Work Item Tracking: Boards, GitHub & Flow
  • DevOps Metrics: Dashboards That Drive Decisions
  • Collaboration: Wikis, Teams & Release Notes

Domain 2: Design and Implement a Source Control Strategy

  • Branching Strategies: Trunk-Based, Feature & Release
  • Pull Requests: Policies, Protections & Merge Rules
  • Repository Management: LFS, Permissions & Recovery

Domain 3: Design and Implement Build and Release Pipelines

  • Package Management: Feeds, Versioning & Upstream
  • Testing Strategy: Quality Gates & Release Gates
  • Test Implementation: Code Coverage & Pipeline Tests
  • Azure Pipelines: YAML from Scratch Free
  • GitHub Actions: Workflows from Scratch Free
  • Pipeline Agents: Self-Hosted, Hybrid & VM Templates
  • Multi-Stage Pipelines: Templates, Variables & Approvals
  • Deployment Strategies: Blue-Green, Canary & Ring Free
  • Safe Rollouts: Slots, Dependencies & Hotfix Paths
  • Deployment Implementations: Containers, Scripts & Databases
  • Infrastructure as Code: ARM vs Bicep vs Terraform
  • IaC in Practice: Desired State & Deployment Environments
  • Pipeline Maintenance: Health, Migration & Retention

Domain 4: Develop a Security and Compliance Plan

  • Pipeline Identity: Service Principals, Managed IDs & OIDC Free
  • Authorization & Access: GitHub Roles & Azure DevOps Security
  • Secrets & Secure Pipelines: Key Vault & Workload Federation
  • Security Scanning: GHAS, Defender & Dependabot

Domain 5: Implement an Instrumentation Strategy

  • Monitoring for DevOps: Azure Monitor & App Insights
  • Metrics & KQL: Analysing Telemetry & Traces

AZ-400 Study Guide

Domain 1: Design and Implement Processes and Communications

  • Work Item Tracking: Boards, GitHub & Flow
  • DevOps Metrics: Dashboards That Drive Decisions
  • Collaboration: Wikis, Teams & Release Notes

Domain 2: Design and Implement a Source Control Strategy

  • Branching Strategies: Trunk-Based, Feature & Release
  • Pull Requests: Policies, Protections & Merge Rules
  • Repository Management: LFS, Permissions & Recovery

Domain 3: Design and Implement Build and Release Pipelines

  • Package Management: Feeds, Versioning & Upstream
  • Testing Strategy: Quality Gates & Release Gates
  • Test Implementation: Code Coverage & Pipeline Tests
  • Azure Pipelines: YAML from Scratch Free
  • GitHub Actions: Workflows from Scratch Free
  • Pipeline Agents: Self-Hosted, Hybrid & VM Templates
  • Multi-Stage Pipelines: Templates, Variables & Approvals
  • Deployment Strategies: Blue-Green, Canary & Ring Free
  • Safe Rollouts: Slots, Dependencies & Hotfix Paths
  • Deployment Implementations: Containers, Scripts & Databases
  • Infrastructure as Code: ARM vs Bicep vs Terraform
  • IaC in Practice: Desired State & Deployment Environments
  • Pipeline Maintenance: Health, Migration & Retention

Domain 4: Develop a Security and Compliance Plan

  • Pipeline Identity: Service Principals, Managed IDs & OIDC Free
  • Authorization & Access: GitHub Roles & Azure DevOps Security
  • Secrets & Secure Pipelines: Key Vault & Workload Federation
  • Security Scanning: GHAS, Defender & Dependabot

Domain 5: Implement an Instrumentation Strategy

  • Monitoring for DevOps: Azure Monitor & App Insights
  • Metrics & KQL: Analysing Telemetry & Traces
Domain 3: Design and Implement Build and Release Pipelines Premium ⏱ ~14 min read

Multi-Stage Pipelines: Templates, Variables & Approvals

Build reusable multi-stage pipelines with YAML templates, variable groups, task groups, and environment-based approvals. Design job execution order with parallelism and dependencies.

Why multi-stage pipelines and templates?

β˜• Simple explanation

Think of a franchise restaurant chain.

Every McDonald’s follows the same recipe book, the same kitchen layout, the same quality checks. The head office creates templates (standard recipes) that every franchise follows. Individual restaurants can customize their menu slightly (local variables), but the core process β€” prep, cook, quality check, serve β€” is enforced by the template.

Multi-stage pipeline templates work the same way. A platform team creates reusable templates that enforce how every team builds, tests, and deploys. Individual teams plug in their specific settings (project name, test framework, deployment target) as variables, but the structure β€” build, test, approve, deploy β€” is standardized. And just like a restaurant needs a manager to approve before opening for service, approvals ensure a human signs off before code reaches production.

As organisations grow from 5 pipelines to 500, maintaining consistency becomes the primary challenge. Multi-stage pipelines with templates solve this by separating pipeline structure (defined by the platform team) from pipeline configuration (defined by each application team).

The AZ-400 exam tests three interrelated concepts:

  • Job execution order β€” parallel vs sequential execution, dependsOn relationships, fan-out/fan-in patterns
  • Reusable elements β€” YAML templates (step, job, stage, variable, extends), task groups, variable groups, and template parameters
  • Checks and approvals β€” environment-based governance using approvals, branch control, business hours, exclusive locks, and custom checks

Job execution order

Parallel vs sequential

By default, jobs within a stage run in parallel and stages run sequentially in Azure Pipelines. You control the order with dependsOn:

PatternAzure PipelinesGitHub Actions
Sequential stagesDefault behaviour (each stage depends on the previous)Use needs: between jobs
Parallel stagesdependsOn: [] (empty array = no dependencies)Jobs without needs: run in parallel by default
Fan-outOne stage triggers multiple parallel stagesOne job triggers multiple parallel jobs via needs:
Fan-inA stage depends on multiple preceding stagesA job has needs: [jobA, jobB, jobC]

Fan-out / fan-in example

stages:
  - stage: Build
    jobs:
      - job: BuildApp
        steps:
          - script: dotnet build

  - stage: TestUnit
    dependsOn: Build
    jobs:
      - job: UnitTests
        steps:
          - script: dotnet test --filter Category=Unit

  - stage: TestIntegration
    dependsOn: Build
    jobs:
      - job: IntegrationTests
        steps:
          - script: dotnet test --filter Category=Integration

  - stage: Deploy
    dependsOn:
      - TestUnit
      - TestIntegration
    jobs:
      - deployment: DeployProd
        environment: production

Build runs first. TestUnit and TestIntegration run in parallel (both depend only on Build). Deploy waits for both test stages to succeed β€” the fan-in point.

Conditions

Use condition: to control whether a stage or job runs based on the outcome of previous stages:

  • succeeded() β€” previous stage succeeded (default)
  • failed() β€” previous stage failed
  • always() β€” run regardless of outcome
  • eq(variables['Build.SourceBranch'], 'refs/heads/main') β€” run only on main branch

YAML templates

Templates are the most powerful reuse mechanism in Azure Pipelines. They let you define pipeline fragments once and include them in multiple pipelines.

Template types

Template TypeWhat It ContainsHow It’s Used
Step templateReusable step definitions- template: steps/build.yml inside a job’s steps
Job templateReusable job definitions- template: jobs/test.yml inside a stage’s jobs
Stage templateReusable stage definitions- template: stages/deploy.yml inside a pipeline’s stages
Variable templateReusable variable definitions- template: vars/common.yml in the variables section
Extends templateWraps the ENTIRE pipeline β€” enforces mandatory structureextends: template: pipeline-template.yml at root level

Template with parameters

A build template that teams can customise:

# templates/dotnet-build.yml
parameters:
  - name: projectPath
    type: string
  - name: dotnetVersion
    type: string
    default: '8.0'
  - name: runTests
    type: boolean
    default: true

steps:
  - task: UseDotNet@2
    inputs:
      version: ${{ parameters.dotnetVersion }}
  - task: DotNetCoreCLI@2
    inputs:
      command: build
      projects: ${{ parameters.projectPath }}
  - ${{ if parameters.runTests }}:
    - task: DotNetCoreCLI@2
      inputs:
        command: test
        projects: ${{ parameters.projectPath }}

Consuming the template:

steps:
  - template: templates/dotnet-build.yml
    parameters:
      projectPath: 'src/MyApi/MyApi.csproj'
      dotnetVersion: '8.0'
      runTests: true

Extends templates β€” enforcing standards

The extends keyword is a game-changer for enterprise governance. It wraps the consuming pipeline inside a template that cannot be overridden:

# enforced-pipeline.yml (owned by platform team)
parameters:
  - name: stages
    type: stageList

stages:
  - stage: SecurityScan
    jobs:
      - job: CodeQL
        steps:
          - task: AdvancedSecurity-Codeql-Init@1
          - task: AdvancedSecurity-Codeql-Analyze@1
  - ${{ each stage in parameters.stages }}:
    - ${{ stage }}

The consuming pipeline:

extends:
  template: enforced-pipeline.yml
  parameters:
    stages:
      - stage: Build
        jobs:
          - job: BuildApp
            steps:
              - script: dotnet build

The security scan always runs first β€” teams cannot remove it because the extends template controls the outer structure. This is how platform teams enforce mandatory security scanning, compliance checks, or notification steps across hundreds of pipelines.

πŸ’‘ Scenario: Nadia's enterprise template strategy at Meridian Insurance

🏒 Nadia Petrov manages 47 pipelines at Meridian Insurance. Elena (compliance) requires that every pipeline runs security scans and sends deployment notifications. Dmitri (VP Engineering) wants consistency without slowing teams down.

Nadia’s template architecture:

  1. Extends template (enforced-pipeline.yml) β€” owned by the platform team. Every pipeline must extend this. It enforces: CodeQL security scan, dependency vulnerability check, deployment notification to Teams
  2. Stage templates β€” stages/deploy-to-aks.yml and stages/deploy-to-app-service.yml β€” reusable deployment patterns
  3. Variable templates β€” vars/production.yml and vars/staging.yml β€” environment-specific connection strings, resource group names, subscription IDs
  4. Step templates β€” steps/dotnet-build.yml, steps/node-build.yml β€” standardised build patterns

Rashid (platform lead) maintains the template repository. Application teams extend the enforced template and plug in their specific stages. If Rashid adds a new compliance check, it applies to all 47 pipelines on the next run β€” no team-by-team updates needed.

The result: Elena gets guaranteed compliance. Teams get productivity (less YAML to write). Dmitri gets consistency across 47 pipelines.

Variables and variable groups

Variable types in Azure Pipelines

Variable TypeScopeDefined InUse Case
Pipeline variablesSingle pipelineYAML variables: sectionBuild configuration, feature flags
Variable groupsShared across pipelinesAzure DevOps LibraryConnection strings, API URLs, shared settings
Secret variablesSingle pipeline or groupAzure DevOps Library (locked)Passwords, tokens, API keys β€” masked in logs
Key Vault linkedVariable group linked to Azure Key VaultAzure Key Vault + LibrarySecrets managed in Key Vault, consumed in pipelines
Runtime variablesSet during pipeline execution##vso[task.setvariable] logging commandDynamic values computed during the build

Variable syntax β€” three expression types

This is a critical exam topic. Azure Pipelines has three distinct expression syntaxes:

SyntaxWhen EvaluatedExampleUse Case
Template expressions ${{ variables.name }}At compile time (before the pipeline runs)${{ parameters.env }}Template parameter insertion, conditional inclusion
Macro syntax $(variableName)At runtime (when the task runs)$(Build.BuildId)Most common β€” used in task inputs and scripts
Runtime expressions $[variables.name]At runtime (when the stage/job/step is evaluated)$[eq(variables.env, 'prod')]Conditional execution at runtime

Key distinction: Template expressions are processed when the YAML is compiled β€” they can generate or remove YAML structure. Macro and runtime expressions are processed during execution β€” they can only substitute values.

Key Vault integration

Variable groups can be linked to Azure Key Vault:

  1. Create a variable group in the Azure DevOps Library
  2. Link it to an Azure Key Vault instance using a service connection
  3. Select which secrets to map as pipeline variables
  4. Reference them with $(secretName) in the pipeline

Secrets from Key Vault are automatically masked in pipeline logs and never written to disk.

πŸ’‘ Exam tip: expression syntax traps

The exam frequently tests whether you understand which syntax to use:

  • Template expression ${{ }} β€” use when you need to conditionally INSERT or REMOVE YAML blocks at compile time. Example: ${{ if eq(parameters.runTests, true) }}: adds or removes a step.
  • Macro $() β€” use in task inputs and script arguments. This is the most common syntax. Example: $(Build.BuildId) in a script command.
  • Runtime expression $[ ] β€” use in condition: fields and when you need dynamic evaluation after the pipeline structure is finalised. Example: condition: $[eq(variables['Build.SourceBranch'], 'refs/heads/main')]

Common mistake: using macro syntax $(param) for template parameters β€” this fails because template parameters are only available at compile time with ${{ parameters.param }}.

Environment checks and approvals

Azure DevOps environments are the governance layer for deployments. Each environment can have multiple checks that must pass before a deployment job proceeds.

Check types

CheckWhat It DoesWhen To Use
ApprovalsOne or more people must approve before deploymentProduction deployments, sensitive environments
Branch controlOnly specific branches can deploy to the environmentOnly main or release/* can reach production
Business hoursDeployments only allowed during specified hoursNo production deploys on weekends or after 6 PM
Exclusive lockOnly one deployment runs at a time per environmentPrevent parallel deployments to the same target
Azure FunctionCall an Azure Function to make a dynamic approval decisionCustom logic β€” check deployment freeze calendars, validate external conditions
REST APICall any REST endpoint and check the responseExternal governance systems, ITSM ticket validation
Required templatePipeline must extend a specific YAML templateEnforce that all pipelines use the approved template

Approval configuration

Approvals are configured on the environment (not in the YAML):

  • Minimum number of approvals β€” how many approvers must sign off
  • Order β€” sequential (each approver in order) or any (any of the specified approvers)
  • Timeout β€” how long to wait before the approval times out and the deployment fails
  • Allow self-approval β€” whether the person who triggered the pipeline can also approve it (disabled by default for separation of duties)

GitHub Actions equivalent

In GitHub Actions, environment protection rules serve the same purpose:

  • Required reviewers map to Azure DevOps approvals
  • Wait timer provides a cool-down delay (similar to Azure business hours gate)
  • Deployment branches map to branch control
  • Custom deployment protection rules map to Azure Function / REST API checks
Question

What are the five YAML template types in Azure Pipelines?

Click or press Enter to reveal answer

Answer

1) Step templates β€” reusable steps within a job. 2) Job templates β€” reusable jobs within a stage. 3) Stage templates β€” reusable stages within a pipeline. 4) Variable templates β€” reusable variable definitions. 5) Extends templates β€” wrap the entire pipeline to enforce mandatory structure. Extends templates are the most powerful for enterprise governance.

Click to flip back

Question

What is an 'extends' template and why is it important?

Click or press Enter to reveal answer

Answer

An extends template wraps the consuming pipeline inside a mandatory outer structure. The platform team owns the template and defines non-negotiable steps (security scans, compliance checks). Application teams provide their stages as parameters but cannot remove the enforced steps. This guarantees governance across hundreds of pipelines.

Click to flip back

Question

What are the three variable expression syntaxes in Azure Pipelines?

Click or press Enter to reveal answer

Answer

1) Template expressions: dollar-double-brace syntax β€” evaluated at compile time, can add/remove YAML structure. 2) Macro syntax: dollar-parentheses β€” evaluated at runtime, used in task inputs and scripts. 3) Runtime expressions: dollar-bracket β€” evaluated at runtime, used in conditions and dynamic logic. Template parameters only work with template expressions.

Click to flip back

Question

Name five environment check types in Azure DevOps.

Click or press Enter to reveal answer

Answer

1) Approvals β€” human sign-off required. 2) Branch control β€” restrict which branches can deploy. 3) Business hours β€” deploy only during specified times. 4) Exclusive lock β€” one deployment at a time per environment. 5) Azure Function / REST API β€” custom dynamic approval logic. Plus: Required template check β€” enforce that pipelines use an approved YAML template.

Click to flip back

Question

How do you link Azure Key Vault secrets to a pipeline?

Click or press Enter to reveal answer

Answer

Create a variable group in Azure DevOps Library, link it to an Azure Key Vault instance via a service connection, and select which secrets to map. Reference them in the pipeline with macro syntax. Secrets are automatically masked in logs and never written to disk. The service connection needs Get/List permissions on the Key Vault.

Click to flip back

Knowledge check

Knowledge Check

Nadia needs to ensure that every pipeline at Meridian Insurance runs a mandatory CodeQL security scan BEFORE any application-defined stages, and application teams cannot skip or remove it. Which template approach achieves this?

Knowledge Check

Jordan defines a pipeline variable using a template expression: dollar-double-brace with variables.buildConfig. A colleague changes it to macro syntax: dollar-parentheses with buildConfig. Both reference the same variable. When does each syntax get evaluated?

Knowledge Check

Meridian Insurance requires that production deployments only happen on weekdays between 8 AM and 6 PM, only from the main branch, and only with approval from both Elena (compliance) and Dmitri (VP Eng). Which Azure DevOps features should Nadia configure on the production environment?

🎬 Video coming soon

Next up: Deployment Strategies β€” design blue-green, canary, rolling, and feature flag deployments that minimise risk and enable safe production releases.

← Previous

Pipeline Agents: Self-Hosted, Hybrid & VM Templates

Next β†’

Deployment Strategies: Blue-Green, Canary & Ring

Guided

I learn, I simplify, I share.

A Guide to Cloud YouTube Feedback

© 2026 Sutheesh. All rights reserved.

Guided is an independent study resource and is not affiliated with, endorsed by, or officially connected to Microsoft. Microsoft, Azure, and related trademarks are property of Microsoft Corporation. Always verify information against Microsoft Learn.