Azure Pipelines YAML templates
Step, job, stage and extends templates, parameters, and how platform teams use them to set standards.
Azure Pipelines builds the final YAML before a run starts. Templates are files inserted into that YAML: step templates (a few steps), job and stage templates (whole jobs or stages), and variable templates. Each declares parameters with types (string, number, boolean, object, stepList) and defaults, which are checked when the pipeline compiles.
Template expressions (${{ }}) run at compile time, so you can loop (each) over a list of environments to make one stage per environment, or include steps conditionally. Runtime expressions ($ ) and macro variables ($( )) are filled in later, while the pipeline runs; mixing them up is the most common template bug.
An extends template controls the whole pipeline: the app's YAML passes its steps in as parameters, and the template decides where they go and can reject what it doesn't allow. Add a required template check on an environment, and only pipelines extending the approved template can deploy there.
Cost. Azure DevOps is free for up to five users. Microsoft-hosted minutes need a free grant or a paid parallel job; self-hosted agents are free.
Use it when
- many pipelines repeat the same stages.
- a platform team needs every pipeline to run security scans.
- you're preparing for AZ-400.
How it works
- Step, job, stage templates
- Reuse pieces with parameters.
- Template expressions
- Compile-time loops and conditions.
- resources: repositories
- Use templates from a shared repository, pinned to a tag.
- extends
- A central template shapes the whole pipeline.
- Required template check
- Environments accept only approved pipelines.
Options
- Includes (templates inserted)
- Flexible reuse; teams can still add anything.
- Extends
- Enforced structure; teams fill in the gaps.
Example. Ironbridge Payments' compliance team requires a dependency scan and a change ticket check before any production deployment. Every pipeline extends secure-pipeline.yml@v4, and production environments have a required template check, so no pipeline can skip them.
Don't confuse it with
- Azure Pipelines templates
- Compile-time expansion, typed parameters, extends with checks.
- GitHub reusable workflows
- Called as jobs at run time, with inputs and secrets.
Words to know
- Template
- A reusable YAML file inserted at compile time.
- extends
- A keyword that makes a pipeline build on a controlling template.
- Required template check
- An environment check that only lets approved templates deploy.
Where to look
- Azure DevOps
- Pipelines
- Environments
- Approvals and checks
Practise it
Read it in the guide, next to the tasks and labs.
Open in DevOps, Hands On