-
Notifications
You must be signed in to change notification settings - Fork 0
AzDoBranchPolicy
Michael Zanatta edited this page Aug 19, 2026
·
4 revisions
AzDoBranchPolicy [string] #ResourceName
{
ProjectName = [String]$ProjectName
RepositoryName = [String]$RepositoryName
BranchName = [String]$BranchName
PolicyType = [String]$PolicyType
[ isEnabled = [Boolean]$isEnabled ]
[ isBlocking = [Boolean]$isBlocking ]
[ PolicySettings = [HashTable]$PolicySettings ]
[ Ensure = [String] {'Present', 'Absent'} ]
}- ProjectName: The name of the Azure DevOps project. This property is mandatory and serves as a key property for the resource.
- RepositoryName: The name of the Git repository. This is a key property.
-
BranchName: The branch to apply the policy to, in
refs/heads/format (e.g.,refs/heads/main). This is a key property. -
PolicyType: The type of branch policy to apply (e.g.,
MinimumReviewerCount,CommentRequirements,MergeStrategy). This is a key property. -
isEnabled: Whether the policy is enabled. Defaults to
$true. -
isBlocking: Whether the policy blocks pull request completion. Defaults to
$true. - PolicySettings: A hashtable of policy-specific settings.
-
Ensure: Specifies whether the policy should exist. Valid values are
PresentandAbsent.
This resource manages branch policies in Azure DevOps Git repositories, enforcing code quality standards such as requiring minimum reviewers, resolving comments, or restricting merge strategies.
Configuration ExampleConfig {
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
}
}
}
}
Start-DscConfiguration -Path ./ExampleConfig -Wait -Verbose# Return the current configuration for AzDoBranchPolicy
$properties = @{
ProjectName = 'MyProject'
RepositoryName = 'MyRepository'
BranchName = 'refs/heads/main'
PolicyType = 'MinimumReviewerCount'
}
Invoke-DscResource -Name 'AzDoBranchPolicy' -Method Get -Property $properties -ModuleName 'AzureDevOpsDscNative'parameters: {}
variables: {
ProjectName: MyProject,
RepositoryName: MyRepository
}
resources:
- name: Main Branch Minimum Reviewer Policy
type: AzureDevOpsDscNative/AzDoBranchPolicy
dependsOn:
- AzureDevOpsDscNative/AzDoGitRepository/MyRepository
properties:
ProjectName: $ProjectName
RepositoryName: $RepositoryName
BranchName: refs/heads/main
PolicyType: MinimumReviewerCount
isEnabled: true
isBlocking: true
PolicySettings:
minimumApproverCount: 2
creatorVoteCounts: false
Ensure: PresentLCM Initialization:
$params = @{
AzureDevopsOrganizationName = "SampleAzDoOrgName"
ConfigurationDirectory = "C:\Datum\DSCOutput\"
ConfigurationUrl = 'https://configuration-path'
JITToken = 'SampleJITToken'
Mode = 'Set'
AuthenticationType = 'ManagedIdentity'
ReportPath = 'C:\Datum\DSCOutput\Reports'
}
Invoke-DscPipelineRunner @params- Assert-BoundParameter
- Assert-ElevatedUser
- Assert-IPAddress
- Assert-Module
- AzDoAPI_0_ProjectCache
- AzDoAPI_1_GroupCache
- AzDoAPI_2_UserCache
- AzDoAPI_3_GroupMemberCache
- AzDoAPI_4_GitRepositoryCache
- AzDoAPI_5_PermissionsCache
- AzDoAPI_6_ServicePrinciple
- AzDoAPI_7_IdentitySubjectDescriptors
- AzDoAPI_8_ProjectProcessTemplates
- AzDoAPI_9_DevOpsClassificationNodes
- Compare-DscParameterState
- Compare-ResourcePropertyState
- ConvertFrom-DscResourceInstance
- ConvertTo-Base64String
- ConvertTo-CimInstance
- ConvertTo-HashTable
- Find-Certificate
- Format-Path
- Get-AzDevOpsOperation
- Get-AzDevOpsServicesApiUri
- Get-AzDevOpsServicesUri
- AzDoAgentPool
- AzDoAgentPoolPermission
- AzDoAgentQueue
- AzDoAreaNodes
- AzDoAreaPermission
- AzDoArtifactFeed
- AzDoArtifactFeedPermission
- AzDoArtifactFeedSettings
- AzDoArtifactFeedView
- AzDoAuditStream
- AzDoBranchPolicy
- AzDoCheckConfiguration
- AzDoDeploymentGroup
- AzDoEnvironmentApproval
- AzDoEnvironmentPermission
- AzDoExtension
- AzDoGitPermission
- AzDoGitRepository
- AzDoGroupMember
- AzDoGroupPermission
- AzDoIterationNodes
- AzDoIterationPermission
- AzDoNotificationSubscription
- AzDoOrganizationGroup
- AzDoOrganizationSettings
- AzDoPipeline
- AzDoPipelineEnvironment
- AzDoPipelinePermission
- AzDoPipelineSettings
- AzDoProcess
- AzDoProcessPermission
- AzDoProject
- AzDoProjectGroup
- AzDoProjectPermission
- AzDoProjectServices
- AzDoRepositorySettings
- AzDoSecurityNamespacePermission
- AzDoServiceConnection
- AzDoServiceConnectionPermission
- AzDoServiceHook
- AzDoTaskGroup
- AzDoTeam
- AzDoTeamMember
- AzDoTeamSettings
- AzDoUserEntitlement
- AzDoVariableGroup
- AzDoVariableGroupPermission
- AzDoWiki
- AzDoWIPTags