Courseiva
Design and implement build and release pipelineseasyMultiple ChoiceObjective-mapped

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.

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 →

How Courseiva writes practice questions · Editorial policy

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.