Study guide
3.3 Branch Policies, Quality Gates & Compliance Restrictions
Microsoft Certified: Azure DevOps Engineer Expert AZ-400
Track your progress as you read
Finished sections get a check mark.
1 Chapter 1: Flow of Work, Traceability & Work Tracking
1.1 Flow of Work, GitHub Flow & Feedback Cycles 1.2 Work Tracking with Azure Boards & GitHub Projects 1.3 End-to-End DevOps Traceability & Quality Tracking
2 Chapter 2: DevOps Metrics, Dashboards & Team Collaboration
2.1 DORA Metrics, Flow Metrics & Dashboard Design 2.2 Lifecycle Metrics Across the Six DevOps Phases 2.3 Work Item Queries, WIQL Charts & Analytics 2.4 Project Documentation: Wikis, Mermaid Diagrams & Release Notes 2.5 Webhooks, Service Hooks & Microsoft Teams ChatOps
3 Chapter 3: Git Branching Strategies & Pull Request Workflows
3.1 Git Branching Models & Strategy Design 3.2 Pull Request Workflows & Merge Strategies 3.3 Branch Policies, Quality Gates & Compliance Restrictions
4 Chapter 4: Repository Management, Optimization & Git Data Operations
4.1 Git LFS Architecture & .gitattributes Tracking 4.2 LFS History Migration, git-fat & File Locking 4.3 Git Repository Scaling, Scalar & Monorepo Governance 4.4 Repository Permissions & Git Tag Governance 4.5 Git Data Recovery & Sensitive-Data Scrubbing
5 Chapter 5: Package Management & Dependency Versioning
5.1 Selecting Package Tools: Azure Artifacts vs. GitHub Packages 5.2 Feed Scoping, Upstream Sources & Pipeline Authentication 5.3 Package Views, Immutability & Quality Promotion 5.4 Dependency Versioning: SemVer, CalVer & Automated Versioning 5.5 Pipeline Artifact Versioning & Artifact Storage Strategy
6 Chapter 6: Pipeline Infrastructure, Agents & Integration
6.1 Selecting a CI/CD Solution: Azure Pipelines vs. GitHub Actions 6.2 GitHub-Azure Pipelines Integration & Hybrid Migration 6.3 Hosted vs. Self-Hosted Agents & Runners 6.4 VMSS Elastic Pools, Container Jobs & Agent Governance 6.5 Pipeline Triggers, Filters & Concurrency Management
7 Chapter 7: YAML Pipeline Architecture & Reusable Elements
7.1 YAML Pipeline Anatomy: Stages, Jobs, Steps & Workspaces 7.2 Job Execution Order: DAG Dependencies, Parallelism & Conditions 7.3 Reusable Elements: Templates, Parameters & Variables 7.4 Variable Groups, Secret Variables & Key Vault Linking 7.5 YAML Environments, Checks & Deployment Approvals
8 Chapter 8: Testing Strategy, Quality Gates & Code Coverage
8.1 Test Strategy Design: Local, Unit & Integration Testing 8.2 Load, Stress & Performance Testing in Pipelines 8.3 Test Execution Tasks, Agents & Results Integration 8.4 Code Coverage Analysis & SonarQube Integration 8.5 Quality Gates, Release Gates & Governance Checks
9 Chapter 9: Modern Deployment Strategies & Zero-Downtime Delivery
9.1 Progressive Delivery: Blue-Green, Canary & Ring Deployments 9.2 Minimizing Downtime: Deployment Slots & Rolling Updates 9.3 Feature Flags with Azure App Configuration & Feature Manager 9.4 Designing the High-Priority Hotfix Path 9.5 Ordered Dependency Deployments, Resiliency & Rollback
10 Chapter 10: Artifact Deployment & Database DevOps
10.1 Containerized Application Delivery: ACR, AKS & Container Apps 10.2 Binary, Web App, Function & Scripted Deployments 10.3 Database DevOps: State-Based & Migration-Based Strategies
11 Chapter 11: Infrastructure as Code (IaC) & Azure Deployment Environments
11.1 Infrastructure as Code Strategy: Bicep, ARM & Terraform 11.2 Desired State Configuration & Azure Machine Configuration 11.3 Azure Deployment Environments (ADE) & Developer Self-Service
12 Chapter 12: Pipeline Maintenance, Health & Modernization
12.1 Pipeline Health, Flaky Tests & Reliability Engineering 12.2 Pipeline Optimization: Caching, Slicing & Concurrency 12.3 Artifact & Build Retention Governance 12.4 Modernizing CI/CD: Classic to YAML Migration
13 Chapter 13: Authentication, Authorization & Identity Governance
13.1 Microsoft Entra Service Principals & Managed Identities 13.2 Service Connections, Workload Identity & Personal Access Tokens 13.3 Azure DevOps Projects, Teams & Permission Evaluation 13.4 Access Levels, GitHub Roles & Outside Collaborators
14 Chapter 14: Secrets Management, Sensitive Data & DevSecOps Scanning
14.1 Azure Key Vault, Secret Variables & Secretless CI/CD 14.2 Security Scanning Strategy, GHAS & Secret Scanning 14.3 CodeQL SAST in Pipelines and Containers 14.4 Software Supply Chain, Container Scanning & Cloud Defender
15 Chapter 15: Telemetry Collection, Azure Monitor & Alerting
15.1 Azure Monitor Architecture, AMA & Data Collection Rules 15.2 Application Insights & Specialized Azure Monitor Insights 15.3 Alerting Rules, Action Groups & GitHub Repository Insights
16 Chapter 16: Telemetry Analysis, Distributed Tracing & SRE Practices
16.1 Distributed Tracing, Application Map & Exception Triage 16.2 KQL Log Analytics, SRE Observability & Error Budgets
3.3 Branch Policies, Quality Gates & Compliance Restrictions
Key Takeaways Explain This Topic AI
Azure Repos branch policies and GitHub rulesets serve as non-bypassable server-side quality gates that protect critical branches from direct commits, unreviewed code, and failed builds.
Regulatory compliance (SOX, ISO 27001) mandates disabling submitter self-approval and enabling vote resets on new pushes to satisfy the Four-Eyes Principle and prevent unreviewed code injection.
Build validation policies automatically trigger CI pipelines with path-filtering criteria, ensuring that code compiling in PR branches satisfies automated unit, integration, and security checks.
Automatically included reviewers can be scoped to specific file paths (such as infrastructure templates or database migrations), guaranteeing that subject matter experts review sensitive changes.
The 'Bypass policies when completing pull requests' permission must be strictly restricted to audited break-glass security groups to handle critical production incidents without compromising daily governance.
Last updated: September 2026
3.3 Branch Policies, Quality Gates & Compliance Restrictions
Quick Summary: Branch policies in Azure Repos and Branch Rulesets in GitHub represent the automated compliance frontier in modern DevOps. They enforce segregation of duties, automated build and security verification, work item traceability, and code review consensus before any change can touch production-critical branches. In Exam AZ-400, mastery of build validation triggers, path-filtered automatic reviewers, and emergency bypass administration is critical.
The Architecture of Server-Side Enforcement
In Git, developers have unrestricted administrative control over their local repositories. They can rewrite history, amend commits, skip local hooks using git commit --no-verify , or delete local branches. Therefore, client-side Git hooks cannot be relied upon for organizational governance or security compliance .
Enterprise compliance requires server-side enforcement mechanisms managed by the Git host (Azure Repos or GitHub). When a developer executes git push , the remote server intercepts the reference update and validates it against active branch policies before writing to the object database. Server-Side Enforcement Boundary:
- [Developer Client] [Azure Repos / GitHub Server Boundary]
- git commit --no-verify ──(push)──► [Branch Policy Interceptor]
- (Bypasses local hooks) ├── Check: Direct push allowed? (DENY)
├── Check: Min 2 reviewers approved?
- ├── Check: Submitter self-approved? (DENY)
- ├── Check: New push since last vote? (RESET VOTES)
├── Check: Build validation pipeline passed?
├── Check: External SonarQube quality gate passed?
└── Check: Work items linked & comments resolved?
- │
- ├── All Passed ──► Commit Written to Main
- └── Any Failed ──► Merge Blocked
- Deep Dive: Azure Repos Branch Policies
Branch policies in Azure DevOps are configured under Project Settings > Repositories > [Select Repository] > Policies > Branch Policies > [Select Branch, e.g., main ] . +-----------------------------------------------------------------------------+
- | Azure Repos Branch Policy Configuration Panel (`refs/heads/main`) |
- +-----------------------------------------------------------------------------+
- | [x] Require a minimum number of reviewers: [ 2 ] |
- | [ ] Allow requestors to approve their own changes (DISABLED FOR SOX) |
- | [x] Prohibit the most recent pusher from approving their own changes |
- | [x] Reset code reviewer votes when there are new changes |
- | |
- | [x] Check for linked work items: [ Required ] |
- | [x] Check for comment resolution: [ Required ] |
- | [x] Limit merge types: [x] Squash merge |
- | |
- | Build Validation: |
- | + Pipeline: 'Core-API-PR-Validation' |
- | + Path filter: '/src/api/*' |
- | + Trigger: Automatic | Requirement: Required |
- | + Build expiration: Immediately when main is updated |
- | |
- | Automatically Included Reviewers: |
- | + Reviewer: '[Project]\Infra-Admins' | Required: True |
- | + Path filter: '/infra/bicep/*' |
- +-----------------------------------------------------------------------------+
- 1. Reviewer Requirements & Segregation of Duties
Minimum Number of Reviewers: Sets the numeric threshold of approvals required (e.g., at least 2 team members).
Allow Requestors to Approve Their Own Changes: When this box is checked, the author of the PR can approve their own changes, counting toward the threshold. For regulatory compliance (SOX Section 404, ISO 27001, PCI-DSS), this setting MUST be DISABLED . Enabling self-approval violates the "Four-Eyes Principle" (segregation of duties).
Prohibit the Most Recent Pusher from Approving: Prevents a reviewer from committing changes to a PR branch and then approving the PR themselves.
Reset Code Reviewer Votes When There Are New Changes: Critical security setting. If Reviewer A approves a PR, and the developer subsequently pushes an additional commit to the PR branch (even a minor fix or formatting tweak), all prior approval votes are automatically reset to Waiting . This prevents the "approval bait-and-switch" vulnerability, where malicious or untested code is injected after approvals are captured.
2. Traceability: Check for Linked Work Items
Requirement Setting: Can be set to Required or Optional .
When set to Required , the PR cannot be completed unless it is linked to at least one Azure Boards work item (User Story, Bug, or Feature).
Auditing Impact: Enforces end-to-end traceability from business requirement to production commit. In an audit, teams can trace any commit on main back through its PR to the exact approved Azure Boards work item.
3. Check for Comment Resolution
When enabled as Required , the PR merge button is disabled as long as any discussion comment left by a reviewer remains in an Active or Pending state.
The author or reviewer must resolve every thread ( Resolved , Closed , or Won't Fix ) before completion is permitted.
4. Limit Merge Types Allowed
Prevents repository history pollution by restricting the merge strategies available in the PR completion modal.
Administrators select permitted options: Basic merge ( --no-ff ), Squash merge ( --squash ), Rebase and fast-forward, or Semi-linear merge.
Exam Pattern: If an organization mandates Trunk-Based Development, administrators check Squash merge only .
5. Build Validation (Automated CI Quality Gate)
Build validation automatically triggers an Azure Pipelines build whenever a PR is created or updated.
Build Pipeline: The target pipeline containing unit tests, linting, build packaging, and static analysis.
Trigger Criteria:
Automatic: Queues immediately upon PR creation or new commit push.
Manual: Must be queued manually by a reviewer (used for expensive, long-running end-to-end test suites).
Policy Requirement: Required (blocks merge if failed) vs. Optional (reports status without blocking).
Build Expiration Rules (Crucial Exam Concept):
Immediately when <branch> is updated: If another developer merges a different PR into main , the validation build for the current PR immediately expires and becomes invalid. The build must re-run against the newly updated target to ensure no semantic merge conflicts exist.
After <n> hours if <branch> has been updated:
Never:
Path Filtering: Scopes the pipeline trigger to specific file patterns using Git globbing. For example, in a monorepo containing /src/api and /src/web , setting a path filter of /src/api/* ensures the backend validation build only runs when backend code is modified, preventing unnecessary pipeline resource consumption when frontend code or /docs are updated.
6. Automatically Included Reviewers & Path-Based Approvals
Allows administrators to automatically attach designated teams to a PR review based on the files modified:
Path Filter Scoping: You specify file patterns (e.g., /infra/terraform/* , *.bicep , /src/auth/* ).
Requirement: Can be configured as Required (their sign-off is mandatory regardless of the minimum reviewer count) or Optional .
Realistic Scenario: Changes to database migration scripts under /src/database/migrations/* automatically add the [Project]\Database-Admins group as a Required reviewer, while front-end changes bypass the DBA team.
7. External Status Checks & Webhooks
External security and quality analysis engines (e.g., SonarQube, Snyk, Mend, Checkmarx) communicate validation statuses back to Azure Repos via the REST API: POST https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/pullRequests/{pullRequestId}/statuses?api-version=7.1
Content-Type: application/json
- {
- "state": "succeeded",
- "description": "SonarQube Quality Gate passed: 0 vulnerabilities, 0 bugs",
- "context": {
- "name": "sonarqube/quality-gate",
- "genre": "continuous-integration"
- }
- }
Under Status Checks , administrators add sonarqube/quality-gate as a Required policy. Even if human reviewers approve and the build validation pipeline succeeds, if the SonarQube quality gate fails (posting a state of failed ), Azure Repos blocks the merge.
Repository Permissions & Emergency "Break-Glass" Administration
Azure Repos uses an Access Control List (ACL) security model for Git repositories: Azure Repos Git Permission Hierarchy:
[Project Level Permissions] ──► [Repository Level Permissions] ──► [Branch Level Permissions]
Key Branch Permissions for `refs/heads/main`:
- ├── Read: Allow
- ├── Contribute: Allow (Can contribute via PR)
- ├── Create branch: Allow
- ├── Manage branch policies: Deny (Project Administrators only)
- └── Bypass policies when completing PR: Deny (EXCEPT Break-Glass Security Group)
- The Break-Glass Emergency Protocol
In a severe production outage (P1 incident), a critical hotfix may need to be merged immediately when the primary CI build validation pipeline is broken or when designated reviewers are unavailable.
The Risk: Granting developers the ability to bypass branch policies creates severe compliance violations and invites unauthorized code pushes.
The AZ-400 Solution:
Create a dedicated security group in Microsoft Entra ID / Azure DevOps named [Project]\Break-Glass-Admins .
Explicitly set Bypass policies when completing pull requests: Allow exclusively for this security group on the main branch.
Set this permission to Deny or Not Set for all other contributor and team groups.
Membership in Break-Glass-Admins must be tightly restricted (e.g., via Microsoft Entra Privileged Identity Management [PIM] with just-in-time activation and manager approval).
Configure Azure Monitor and Azure DevOps Audit Streams to trigger real-time, high-priority security alerts whenever an audit event with action Policy.Bypass is logged.
GitHub Branch Protection Rules & Modern Rulesets
GitHub provides equivalent enforcement through Branch Protection Rules and the more modern Repository Rulesets .
Rulesets vs. Classic Branch Protection
Classic Branch Protection: Applied per repository to individual branch patterns (e.g., main ). Difficult to manage across hundreds of repositories in an enterprise organization.
Repository Rulesets: Can be applied across multiple target repositories simultaneously at the organization level. They support versioning, evaluation mode (testing rules without enforcing), and granular bypass lists based on roles, teams, or GitHub Apps.
Key GitHub Protection Settings
Setting Technical Behavior & Enforcement
Require a pull request before merging Blocks direct git push to the branch. Mandates PR creation.
Required approvals Specifies the number of distinct human approvals required (1 to 10).
Dismiss stale pull request approvals Equivalent to Azure Repos 'Reset votes on new changes'. New commits revoke prior approvals.
Require review from Code Owners Reads the .github/CODEOWNERS file. Mandates approvals from specific teams based on paths.
Require status checks to pass Mandates that specific GitHub Actions jobs or external webhooks report success.
Require branches to be up to date Strict Status Checking: Forces developers to rebase/merge main into their PR branch before merging.
Require conversation resolution Blocks merging if any PR conversation thread remains open.
Require signed commits Enforces GPG/SSH/S/MIME cryptographic commit signing; rejects unsigned commits.
Require linear history Rejects merge commits ( --no-ff ), enforcing squash or rebase workflows.
Do not allow bypassing Enforces all above rules on organization and repository administrators.
Compliance Policy Matrix
This table summarizes how enterprise compliance requirements map directly to platform configurations:
Compliance / Governance Goal Azure Repos Implementation GitHub Implementation
Segregation of Duties (SOX 404) Disable: Allow requestors to approve own changes Disable: Allow authors to approve their own PRs
Zero Stale Approvals Enable: Reset reviewer votes on new changes Enable: Dismiss stale pull request approvals when new commits are pushed
Path-Based Expert Review Automatically included reviewers with path filter .github/CODEOWNERS + Require review from Code Owners
Static Security Scanning Gate Status Check requiring SonarQube / Snyk webhook Require status check: CodeQL or Security/SonarQube
Prevent Broken Deployments Build Validation pipeline marked Required Require status checks to pass before merging
Semantic Conflict Prevention Build expiration: Immediately when main updated Require branches to be up to date before merging (Strict)
Full Requirement Traceability Policy: Check for linked work items (Required) Azure Boards GitHub App requiring linked issue/AB#
Audited Emergency Access Restrict Bypass policies to PIM Break-Glass group Configure Bypass list in Rulesets restricted to Emergency Role