Microsoft Certified: DevOps Engineer ExpertDesign and implement source controlEasy
A company is implementing a Git-based source control strategy in Azure Repos. They want to enforce a policy where all code changes must go through a pull request (PR) process and require at least two approved reviewers before merging into the `main` branch. Additionally, they want to ensure that a successful build pipeline run is completed for every PR before it can be merged. Which Azure Repos features should they configure?
- ARepository settings and service hooks.
- BPull request templates and merge strategies.
- CBranch policies and required reviewers.
- DGit commit hooks and branch permissions.
Show answer & explanationAnswer & explanation
Correct answer: C. Branch policies and required reviewers.
Branch policies in Azure Repos allow you to enforce various requirements on branches, including requiring pull requests, setting a minimum number of reviewers, and mandating successful build validations before merging. This directly addresses all the stated requirements.
Why the other options are wrong
- A. Repository settings are too broad; service hooks notify external systems but don't enforce merge policies.
- B. Pull request templates standardize PR descriptions; merge strategies define how merges occur but don't enforce approval or build requirements.
- D. Git commit hooks are client-side and easily bypassed; branch permissions alone don't enforce PRs or build validation.
Azure Repos Branch Policies
Rules enforced on specific branches in Azure Repos to maintain code quality, ensure collaboration, and control merges.
- Enforce pull request workflow.
- Require minimum reviewers and successful builds.
- Prevent direct pushes to protected branches.
Memory trick: Policies protect your main branch from bad merges.