AZ-400 Trigger on GitHub main branch push Practice Question
You need to trigger a pipeline whenever changes are pushed to the 'main' branch of a GitHub repository. Which trigger should you configure in the YAML pipeline?
⚠ Common exam trap
Many exam-takers confuse the `trigger` (CI push trigger) with the `pr` (pull request trigger), or incorrectly assume that a resource-level trigger is required for the self repository, when the root-level `trigger` is the correct and simplest configuration for push-based CI on the same repository.
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
✓
trigger: branches: include: - main
The `trigger` keyword at the root of a YAML pipeline defines the CI trigger that automatically starts a pipeline run when changes are pushed to the specified branch. By including `main` under `branches.include`, the pipeline will trigger on any push to the `main` branch of the GitHub repository, which is the standard way to set up a CI trigger for a single branch.
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: branches: include: - main
Why this is correct
This is the standard YAML syntax in Azure Pipelines to trigger a pipeline on a push to the main branch in GitHub. It uses the `trigger` keyword with branch filters under `branches.include`, causing the pipeline to run automatically when commits are pushed to that branch.
- ✗
pr: branches: include: - main
Why it's wrong here
The `pr` keyword is used to configure pull request triggers, not push triggers. It would trigger the pipeline on pull request creation or updates, not on direct pushes to the main branch. Thus it does not satisfy the requirement of triggering on a GitHub main branch push.
- ✗
resources: repositories: - repository: self trigger: branches: include: - main
Why it's wrong here
This syntax defines a repository resource and sets a trigger for that specific resource. However, for the self repository (the one containing the pipeline), the trigger should be defined at the top level using `trigger`, not under `resources.repositories`. Also, specifying `repository: self` and then a trigger inside it is not the correct way to set up a pipeline trigger for the main branch.
- ✗
schedules: - cron: "0 0 * * *" branches: include: - main
Why it's wrong here
The `schedules` keyword is used to define scheduled triggers based on cron expressions, not to respond to git push events. This would run the pipeline at a specific time daily (midnight) rather than on a push to main, so it does not achieve the desired push-trigger behavior.
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.
✓trigger: branches: include: - mainCorrect answer▾
Why this is correct
This is the standard YAML syntax in Azure Pipelines to trigger a pipeline on a push to the main branch in GitHub. It uses the `trigger` keyword with branch filters under `branches.include`, causing the pipeline to run automatically when commits are pushed to that branch.
✗pr: branches: include: - mainWrong answer — click to see why▾
Why this is wrong here
This triggers on pull request creation, not on push.
✗resources: repositories: - repository: self trigger: branches: include: - mainWrong answer — click to see why▾
Why this is wrong here
This is for triggering from another repository, not the self repo.
✗schedules: - cron: "0 0 * * *" branches: include: - mainWrong answer — click to see why▾
Why this is wrong here
This is a scheduled trigger, not on push.
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?”
Go deeper
Related to this question
About these practice questions
One of 823 original AZ-400 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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.