Question 636 of 823
AZ-400 Conditional deployment strategies Practice Question
Which two of the following are valid strategies to implement conditional deployment in a YAML pipeline? (Choose 2)
⚠ Common exam trap
Test-takers frequently confuse dependency conditions (like `succeededOrFailed`) with custom conditional logic, not realizing that dependency conditions are predefined and not a general-purpose strategy for implementing conditional deployment based on arbitrary criteria like branch names or variables.
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
✓
Use the 'condition' property on a stage
Both 'condition' property and template expressions with parameters are valid strategies for conditional deployment in YAML pipelines. The 'condition' property (e.g., `eq(variables['Build.SourceBranch'], 'refs/heads/main')`) controls at runtime whether a stage, job, or step runs, based on variables or expressions. Template expressions with parameters (e.g., `${{ if eq(parameters['environment'], 'prod') }}`) allow you to conditionally include or exclude parts of the pipeline at compile time, making them a powerful tool for conditional deployment based on parameters.
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 the 'condition' property on a stage
Why this is correct
The 'condition' property on a stage in Azure Pipelines evaluates expressions at runtime, such as `condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))`, and is the native, declarative way to control whether a stage executes during a pipeline run, making it ideal for conditional deployment strategies.
- ✓
Use template expressions with parameters
Why this is correct
Template expressions with parameters, like `${{ if eq(parameters.environment, 'production') }}`, are evaluated at compile time, allowing you to conditionally include or exclude stages, jobs, or steps based on parameter values or other context, thus enabling flexible conditional pipeline definition for deployments.
- ✗
Configure stage filters in the triggers section
Why it's wrong here
In Azure Pipelines, triggers only determine when a pipeline run is initiated (e.g., via branch paths or tags); there is no concept of 'stage filters' in the triggers section that can conditionally enable or disable specific stages within a run. Stage execution is governed by conditions, dependencies, or templates, not trigger filters.
- ✗
Use dependency conditions like 'succeededOrFailed'
Why it's wrong here
While `succeededOrFailed()` is a valid dependency condition, it only checks that prior stages have completed with either success or failure, which is useful for cleanup or post-run tasks but does not allow evaluation of custom variables, parameters, or environment-specific logic needed for nuanced conditional deployment strategies.
- ✗
Add a PowerShell script to check environment
Why it's wrong here
A PowerShell script runs inside a job after the stage has already started, so it cannot prevent the stage from being entered. To conditionally deploy, you must use declarative mechanisms like stage conditions, template expressions, or dependency checks that are evaluated before the stage begins, not an imperative script that checks the environment at runtime.
Option-by-option analysis
Why each answer is right or wrong
Understanding why wrong answers are wrong — and when they would be correct — is what separates a 750 score from a 900. The AZ-400 exam frequently reuses these exact scenarios with slightly different constraints.
✓Use the 'condition' property on a stageCorrect answer▾
Why this is correct
The 'condition' property on a stage in Azure Pipelines evaluates expressions at runtime, such as `condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))`, and is the native, declarative way to control whether a stage executes during a pipeline run, making it ideal for conditional deployment strategies.
✗Configure stage filters in the triggers sectionWrong answer — click to see why▾
Why this is wrong here
Stage filters are for triggers, not conditions within a pipeline.
✗Use dependency conditions like 'succeededOrFailed'Wrong answer — click to see why▾
Why this is wrong here
Dependency conditions are built-in for run order, not for custom conditional logic.
✗Add a PowerShell script to check environmentWrong answer — click to see why▾
Why this is wrong here
While possible, it's not a pipeline-native strategy; the question asks for valid strategies in YAML.
Analysis generated from the official AZ-400blueprint and verified against question context. The “when correct” sections are what AI assistants cite when candidates ask “what’s the difference between these options?”
About these practice questions
Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →
Last reviewed: Jun 11, 2026
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.
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
Sign in to join the discussion.