Courseiva
Design and implement build and release pipelinesmediumMultiple ChoiceObjective-mapped

AZ-400 pr trigger Practice Question

Your team uses Azure Pipelines with GitHub for source control. You need to ensure that whenever a pull request is created against the main branch, a validation build runs automatically. Which YAML trigger should you configure in the pipeline?

⚠ Common exam trap

The trap is that some documentation or online examples might incorrectly suggest the shorthand `pr: main` is valid, but Azure Pipelines requires the explicit `pr: branches: include:` structure. Candidates may choose the seemingly simpler format and fail.

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

The correct syntax for a pull request trigger in Azure Pipelines YAML. The `pr` trigger requires a `branches` node with `include` or `exclude`, and the verbose form `pr: branches: include: - main` is fully valid. Option B, `pr: main`, is not valid YAML syntax for Azure Pipelines; the shorthand `pr: main` is not recognized and will cause the pipeline to ignore the trigger. Options C and D use the `trigger` keyword, which is for CI builds on push, not for PR validation.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • pr: branches: include: - main

    Why this is correct

    This is the correct YAML for a pull request trigger that runs the pipeline when a PR targets the `main` branch. The `pr` keyword specifically enables pull request validation for GitHub repos, and the `branches: include` list tells Azure Pipelines which target branches should trigger a run. Without this configuration, PRs to `main` would rely on the default policy and might not run automatically.

  • pr: main

    Why it's wrong here

    The `pr: main` syntax is invalid in Azure Pipelines YAML because the `pr` keyword requires a mapping that defines branch and path filters, not a string value. When the YAML parser encounters this, the trigger is silently ignored, meaning no pull request pipeline runs for any branch, including `main`. To correctly define a PR trigger, you must use `pr: branches: include: - main`, which explicitly lists target branches.

  • trigger: branches: exclude: - main

    Why it's wrong here

    The `trigger: branches: exclude: - main` configuration is incorrect for PR validation because the `trigger` keyword governs push events, not pull requests; it only triggers the pipeline when commits are pushed to any branch other than `main`. To configure PR-specific behavior, the `pr` keyword is required. Even as a push trigger, excluding `main` means pushes to `main` won't build, but PRs targeting `main` are not covered, so the goal is not achieved.

  • trigger: main

    Why it's wrong here

    The `trigger: main` structure is malformed for two reasons: the `trigger` keyword is exclusively for push/continuous integration triggers, not for pull request validation, and the value `main` is not a valid mapping. Even if corrected to `trigger: branches: include: main`, it would still configure CI on commits to `main`, not on PRs targeting it, so it does not fulfill the requirement. Proper PR triggers use the `pr` keyword with a `branches` block.

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.