AZ-400 Practice Question: Design and implement build and release pipelines
You are designing a multi-stage YAML pipeline that builds a Docker image and deploys it to Azure Kubernetes Service (AKS). You want to reuse the Docker build steps across multiple stages. What is the best approach?
⚠ Common exam trap
It's easy for candidates to confuse stage templates with step templates, thinking that reusing an entire stage is the same as reusing steps within a stage, but the question specifically asks for reusing 'Docker build steps' across stages, not entire stages.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Create a YAML template and reference it from each stage.
YAML templates in Azure Pipelines allow you to define reusable step, job, or stage definitions in a separate file and reference them using the `template` keyword. This approach promotes DRY (Don't Repeat Yourself) principles, simplifies maintenance, and ensures consistency when the same Docker build steps are needed across multiple stages in a multi-stage pipeline.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Use a stage template.
Why it's wrong here
A stage template encapsulates an entire stage, including its jobs and steps. This option fails because the requirement is to reuse specific *steps* (Docker build steps) across *multiple stages*, not to reuse an entire stage itself. Using a stage template would mean reusing the whole stage structure, which isn't the precise need here. It is tempting because templates are for reusability. A stage template is suitable when you need to reuse an entire, self-contained stage definition, perhaps with varying parameters, across different parts of a pipeline or in multiple pipelines.
- ✗
Define the steps as variables and reference them.
Why it's wrong here
Variables in Azure Pipelines are string key-value pairs used for configuration values, not for executable YAML definitions. You cannot store a sequence of steps in a variable and expect them to run, because variables are interpolated as text, not parsed as pipeline tasks. Thus this approach cannot reuse Docker build steps across stages.
- ✓
Create a YAML template and reference it from each stage.
Why this is correct
A YAML template is the standard Azure Pipelines mechanism for reusing steps, jobs, or even entire stages. By extracting the Docker build steps into a `steps` template file and referencing it with `template:` inside each stage's `steps`, you avoid duplication and keep the build logic consistent and maintainable.
- ✗
Create a separate job and call it from each stage.
Why it's wrong here
Jobs are the top-level units of execution inside a stage; there is no construct to 'call' a separate job from within a stage's job list. While you could define a job in a template and include it via `template:` at the job level, a standalone job cannot be invoked inline from each stage, making this less direct than a steps template and not the correct approach.
Go deeper
Related to this question
Learn chapter
Introduction to DevOps and Azure DevOps
Key term
Azure Pipelines
Azure Pipelines is a cloud-based CI/CD service from Microsoft that automatically builds, tests, and deploys code to any platform or cloud.
Key term
Anthos
Anthos is a Google Cloud platform that lets you run applications consistently across different computing environments, like on-premises data centers and multiple public clouds.
About these practice questions
This AZ-400 question is part of Courseiva's 823-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This AZ-400 practice question is part of Courseiva's free Microsoft certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the AZ-400 exam.