AZ-400 Practice Question: Design and implement build and release pipelines
Your team uses Azure Pipelines with a YAML pipeline. You need the pipeline to run only when changes are pushed to the main branch, but also run on a nightly schedule. Which trigger configuration should you implement?
⚠ Common exam trap
A common mix-up: candidates confuse pull request triggers with push triggers, or assuming that a schedule trigger alone can also handle branch pushes.
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 a `schedules` trigger with a cron expression and a `trigger` block that includes only the main branch.
The correct configuration uses a `trigger` block that includes only the main branch to run on pushes, plus a `schedules` block with a cron expression for nightly runs. Both triggers can be defined in the same YAML file and operate independently. This satisfies the need to run on main branch changes and on a schedule without extraneous runs.
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 only a `schedules` trigger with a cron expression and remove the `trigger` block.
Why it's wrong here
If you remove the `trigger` block, the pipeline will not run on pushes to main. The `schedules` trigger alone only runs at the specified times, not on code changes. This fails the requirement to run when changes are pushed to main. You need both triggers to satisfy the scenario.
- ✓
Use a `schedules` trigger with a cron expression and a `trigger` block that includes only the main branch.
Why this is correct
The `trigger` block with `branches: include: [main]` ensures the pipeline runs on pushes to main, while `schedules` with a cron expression enables nightly runs. Both triggers can coexist in the same YAML file. This configuration meets the requirement of running on main pushes and on a schedule without unwanted runs on other branches.
- ✗
Use a `pipeline` trigger with `branches: include: [main]` and a `cron` trigger.
Why it's wrong here
`pipeline` triggers are used to trigger a pipeline from another pipeline (pipeline completion triggers), not for branch pushes or schedules. A `cron` trigger is not a valid YAML element; schedules use the `schedules` keyword. This combination would not run on main pushes or on a schedule as required.
- ✗
Use a `trigger` block with `branches: include: [main]` and add a `pr` trigger for the main branch.
Why it's wrong here
A `pr` trigger runs the pipeline for pull requests targeting the specified branches, not for pushes or schedules. This would cause runs on PRs, which is not requested, and would not provide nightly runs. The scenario requires a scheduled run, so a `pr` trigger is incorrect here.
Go deeper
Related to this question
Learn chapter
Implementing Security and Compliance in Pipelines
Key term
Branch
A branch is a pointer to a specific commit in a version control system that allows you to work on features or fixes in isolation from the main codebase.
Key term
Azure Pipelines
Azure Pipelines is a cloud-based CI/CD service from Microsoft that automatically builds, tests, and deploys code to any platform or cloud.
About these practice questions
One of 696 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 and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Microsoft exam blueprint
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.