AZ-400 Practice Question: Design and implement a source control strategy
Your team uses GitHub and wants to automatically label pull requests based on the content of the changes (e.g., 'frontend' for changes in /frontend folder, 'backend' for /backend). Which approach should you use?
⚠ Common exam trap
Candidates often confuse CODEOWNERS (which assigns reviewers) with label automation, leading candidates to pick option D despite it having no labeling functionality.
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
✓
Create a GitHub Actions workflow that runs on pull_request events and uses an action like 'actions/labeler' to add labels based on path patterns.
GitHub Actions provides a native, event-driven way to automate labeling based on pull request changes. The 'actions/labeler' action specifically inspects file paths in the diff and applies labels defined in a configuration file, making it the simplest and most maintainable solution for path-based labeling.
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 branch protection rules to require specific labels based on branch name patterns.
Why it's wrong here
Branch protection rules enforce quality gates on pull requests—such as required status checks, required reviewers, and commit signing—but they do not contain any mechanism for automatically adding labels. Labels are metadata that must be set by an API call, a webhook handler, or a GitHub Action, so branch protection rules alone cannot auto-label a PR.
- ✗
Set up a webhook that triggers an Azure Function to parse the pull request diff and add labels.
Why it's wrong here
A webhook-triggered Azure Function can parse a pull request diff and add labels, but this approach fails because GitHub already provides a native mechanism—GitHub Actions with a `paths` filter—that directly labels PRs based on changed folders without requiring custom infrastructure. It is tempting because webhooks are a generic integration pattern for reacting to GitHub events, and an Azure Function would be correct if the labelling logic required complex external processing (e.g., calling a third-party API) that GitHub Actions cannot perform natively.
- ✓
Create a GitHub Actions workflow that runs on pull_request events and uses an action like 'actions/labeler' to add labels based on path patterns.
Why this is correct
The actions/labeler GitHub Action runs on the pull_request event and uses a declarative configuration file (typically .github/labeler.yml) to map file path patterns to labels. When a PR modifies files matching a pattern, the action automatically adds the corresponding label, making this the purpose-built, native GitHub solution for path-based auto-labeling.
- ✗
Use a CODEOWNERS file to assign labels based on file paths.
Why it's wrong here
A CODEOWNERS file designates specific users or teams as owners of files/directories, and GitHub automatically requests their review when a PR touches those paths. It has no functionality to add or manage labels—labels must be applied via the GitHub API, GitHub Actions, or another automation layer—so using CODEOWNERS for labeling is fundamentally incorrect.
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
GitHub
GitHub is a cloud-based platform for storing, tracking, and collaborating on code using Git version control.
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.