AZ-400 Practice Question: Design and implement build and release pipelines
You are setting up a build pipeline for a .NET Core application. The build should run on every pull request to the 'main' branch. Which trigger configuration should you use in the YAML pipeline?
⚠ Common exam trap
Many exam-takers confuse the `trigger` keyword (for CI pushes) with the `pr` keyword (for pull request validation), leading them to incorrectly nest PR settings under `trigger` or use `trigger` alone for PR scenarios.
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
✓
pr: branches: include: - main
In Azure Pipelines YAML, the `pr` trigger is used to define pull request validation triggers, separate from the `trigger` keyword which controls CI triggers on branch pushes. By specifying `pr: branches: include: - main`, the pipeline will automatically run on every pull request targeting the `main` branch, which matches the requirement exactly.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
trigger: pr: branches: include: - main
Why it's wrong here
This YAML is invalid because 'pr' is a top-level key in Azure Pipelines, not a sub-key of 'trigger'. Placing it under 'trigger' will cause a schema validation error, so the pipeline won't run PR validation.
- ✗
trigger: branches: include: - main
Why it's wrong here
The 'trigger' key defines continuous integration (CI) builds that run on commits to branches, not pull request validation. To trigger builds on pull requests targeting main, you must use the 'pr' key instead, otherwise PRs won't trigger a build.
- ✓
pr: branches: include: - main
Why this is correct
This YAML snippet correctly configures a pull request trigger for the pipeline using the top-level `pr` key. By specifying `branches: include: main`, the pipeline will automatically run as PR validation whenever a pull request targets the `main` branch, which is exactly the desired behavior. Unlike `trigger`, which controls CI builds on branch pushes, `pr` is the dedicated mechanism for pull request validation in Azure Pipelines. This configuration is valid and requires no additional nesting or modifiers to achieve the stated goal.
- ✗
pr: autoCancel: false branches: include: - '*'
Why it's wrong here
Using 'include: - *' configures PR triggers for pull requests targeting all branches, not just 'main'. Additionally, 'autoCancel: false' is a separate setting, but the branch wildcard over-scopes the trigger, causing builds on PRs to non-main branches as well.
Go deeper
Related to this question
Learn chapter
Introduction to DevOps and Azure DevOps
Key term
Pull request
A pull request is a way for a developer to propose changes to a codebase and ask other team members to review and merge them into the main project.
Key term
YAML pipeline
A YAML pipeline is a text-based file written in YAML format that defines an automated series of steps for building, testing, and deploying software in a continuous integration and continuous delivery (CI/CD) system.
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.