Skip to content

AzDoBranchPolicy

github-actions[bot] edited this page Aug 19, 2026 · 4 revisions

Parameters

Parameter Attribute DataType Description Allowed Values
ProjectName Key System.String The Azure DevOps project name.
BranchName Required System.String The branch ref name (e.g. 'refs/heads/main').
PolicyType Required System.String The policy type display name (e.g. 'MinimumReviewerCount').
RepositoryName Required System.String The Git repository name.
Ensure Write Ensure Present, Absent
isBlocking Write System.Boolean Whether the policy is blocking. Default is $true.
isEnabled Write System.Boolean Whether the policy is enabled. Default is $true.
PolicySettings Write System.Collections.Hashtable Policy-type-specific settings hashtable.
LookupResult Read System.Collections.Hashtable

Description

The AzDoBranchPolicy class manages branch policy configurations on a Git repository branch within an Azure DevOps project.

Examples

Example 1

This example shows how to ensure that a minimum reviewer count branch policy exists on the 'main' branch of the 'MyRepository' repository.

Configuration Example
{
    Import-DscResource -ModuleName 'AzureDevOpsDscNative'

    node localhost
    {
        AzDoBranchPolicy 'AddBranchPolicy'
        {
            Ensure         = 'Present'
            ProjectName    = 'MyProject'
            RepositoryName = 'MyRepository'
            BranchName     = 'refs/heads/main'
            PolicyType     = 'MinimumReviewerCount'
            isEnabled      = $true
            isBlocking     = $true
            PolicySettings = @{
                minimumApproverCount = 2
                creatorVoteCounts    = $false
            }
        }
    }
}

Example 2

This example shows how to update an existing branch policy, changing the minimum reviewer count and making it non-blocking.

Configuration Example
{
    Import-DscResource -ModuleName 'AzureDevOpsDscNative'

    node localhost
    {
        AzDoBranchPolicy 'UpdateBranchPolicy'
        {
            Ensure         = 'Present'
            ProjectName    = 'MyProject'
            RepositoryName = 'MyRepository'
            BranchName     = 'refs/heads/main'
            PolicyType     = 'MinimumReviewerCount'
            isEnabled      = $true
            isBlocking     = $false
            PolicySettings = @{
                minimumApproverCount = 1
                creatorVoteCounts    = $true
            }
        }
    }
}

Commands

Resources

Clone this wiki locally