BrainyBeeBrainyBee
ExploreBlogStart Studying
HomeDesigning and Implementing Microsoft DevOps Solutions (AZ-400)Develop pipelines by using YAML
Lesson786 words

Develop pipelines by using YAML

Develop pipelines by using YAML

A YAML pipeline is a file in your repository. That single fact drives everything else in this objective: the pipeline is versioned, reviewed and branched exactly like the code it builds, and a change to it travels through a pull request rather than through a portal.

The four levels

Every YAML pipeline is the same nesting, whether or not you write all of it:

Loading Diagram...
Figure 1 — Mermaid diagram
LevelRuns onPurpose
Stage—A major division: build, test, deploy to an environment
JobOne agentA unit of work scheduled to a single agent
StepThe job's agentOne script, task, powershell, bash or checkout
Deployment jobOne agent, against an environmentA job with a deployment strategy and lifecycle hooks

You can omit levels. A pipeline that is only steps: is legal — Azure Pipelines implies a single job in a single stage.

The default that catches people out

Jobs in a stage run in parallel by default. Ordering only happens when you set dependsOn. Every pipeline must contain at least one job with no dependencies, or there is nothing to start with.

yaml
jobs: - job: A steps: - script: echo "A and B start together" - job: B steps: - script: echo "no dependsOn, so B does not wait for A" - job: C dependsOn: [A, B] # C waits for BOTH condition: succeeded() # ...and only if both succeeded steps: - script: echo "C runs last"

Note the asymmetry worth remembering: job dependencies are not supported in classic release pipelines — multiple jobs there run in sequence.

Conditions

dependsOn decides order. condition decides whether. Setting a custom condition replaces the implicit succeeded(), which is why a bare condition: always() will run a step even after a cancellation.

ConditionRuns when
succeeded()The default — all dependencies succeeded
failed()A dependency failed. Use for rollback and notification jobs
always()Always, including after cancellation. Use for cleanup
canceled()The run was cancelled
succeededOrFailed()Finished either way, but not cancelled

Combine them with the expression functions:

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

Deployment jobs and strategies

A deployment job targets an environment, and that is what gives you deployment history and the place where checks and approvals attach.

yaml
jobs: - deployment: DeployWeb environment: production strategy: runOnce: preDeploy: steps: - script: echo "initialise" deploy: steps: - script: echo "deploy the app" routeTraffic: steps: - script: echo "shift traffic to the new version" postRouteTraffic: steps: - script: echo "watch health before declaring success" on: failure: steps: - script: echo "roll back" success: steps: - script: echo "clean up"

Three strategies exist, and the difference is examinable:

StrategyBehaviourConstraint
runOnceEach lifecycle hook executes onceThe simplest, and the default choice
rollingReplaces instances in batches of maxParallelVM resources only
canaryShips to a small slice, then increasesUsed with increments

Under rolling, the hooks run once per batch, not once per deployment.

Reuse: two different template mechanisms

yaml
# Insert — pulls content INTO your pipeline steps: - template: templates/npm-steps.yml parameters: vmImage: ubuntu-latest # Extend — your pipeline is CONSTRAINED BY the template extends: template: templates/secure-pipeline.yml parameters: buildSteps: - script: npm ci

template: composes. extends: is the security control — the extended template decides what the consuming pipeline is permitted to do, which is what makes it the answer whenever a question mentions enforcing organisational policy on pipelines someone else writes.

Parameters are typed, and the type is what makes an extends-template enforceable:

yaml
parameters: - name: buildSteps type: stepList # only steps may be injected here default: []

What to carry into the exam

  • Stages → jobs → steps, and a deployment job is a job with a strategy.
  • Jobs are parallel until you write dependsOn.
  • A custom condition replaces succeeded(); always() survives cancellation.
  • rolling is VM-only and its hooks run per batch.
  • extends constrains, template composes.
  • Typed parameters (stepList, jobList, stageList, object, string) are what let an extends-template enforce policy rather than merely suggest it.

Primary sources

  • https://learn.microsoft.com/en-us/azure/devops/pipelines/process/phases
  • https://learn.microsoft.com/en-us/azure/devops/pipelines/process/conditions
  • https://learn.microsoft.com/en-us/azure/devops/pipelines/process/deployment-jobs
  • https://learn.microsoft.com/en-us/azure/devops/pipelines/process/templates
All Designing and Implementing Microsoft DevOps Solutions (AZ-400) Study Resources

Related Notes

  • Agent and runner infrastructure421 words
  • Agent and runner infrastructure — quick notes150 words
  • Alerting on pipeline events255 words
  • Alerting on pipeline events — quick notes94 words
  • Analyzing usage and application performance241 words
  • Analyzing usage and application performance — quick notes73 words
  • Appropriate access levels217 words
  • Appropriate access levels — quick notes85 words
  • Automating container scanning277 words
  • Automating container scanning — quick notes96 words
  • Automating documentation from Git history191 words
  • Automating documentation from Git history — quick notes55 words

Ready to study Designing and Implementing Microsoft DevOps Solutions (AZ-400)?

Practice tests, flashcards, and all study notes — free, no sign-up.

Start Studying

Ready to study Designing and Implementing Microsoft DevOps Solutions (AZ-400)?

Practice tests, flashcards, and all study notes — free, no sign-up needed.

Start Studying — Free
Designing and Implementing Microsoft DevOps Solutions (AZ-400) ResourcesExplore All HivesBlogHome

© 2026 BrainyBee. Free AI-powered exam prep.

Loading Diagram...
Flowchart, top to bottom. Pipeline<br/><i>azure-pipelines.yml</i> connects to Stage: Build. Pipeline<br/><i>azure-pipelines.yml</i>"] --> S1["Stage: Build connects to Stage: Deploy. S1 connects to Job: compile. S1 connects to Job: test. S2 connects to Deployment job: web. J1 connects to Step: script. J1 connects to Step: task. J3 connects to Strategy: runOnce.