-
Notifications
You must be signed in to change notification settings - Fork 0
AzDoProjectPermission
The AzDoProjectPermission DSC resource is used to manage permissions at the project level in Azure DevOps. It allows you to configure and enforce the desired state of permissions assigned to groups for an entire project, controlling high-level access to project features and administration capabilities. These permissions cascade to project-level resources unless overridden by more specific permissions.
AzDoProjectPermission [string] #ResourceName
{
ProjectName = [String] $ProjectName
GroupName = [String] $GroupName
[ isInherited = [Boolean] $isInherited ]
[ Permissions = [Hashtable[]] $Permissions ]
[ Ensure = [String] {'Present', 'Absent'} ]
[ DependsOn = [String[]] ]
[ PsDscRunAsCredential = [PSCredential] ]
}- ProjectName [String] - The name of the Azure DevOps project. This is the unique identifier for the project at which permissions are managed.
- GroupName [String] - The name of the group to which project-level permissions are assigned. The group must exist in the project or organization.
-
isInherited [Boolean] - Specifies whether the permissions are inherited from the organization level. Default is
$true. When set to$false, only explicitly assigned permissions apply. -
Permissions [Hashtable[]] - An array of hashtables specifying the project-level permissions to be assigned. Each hashtable should contain:
-
Permission- The name of the permission (e.g., 'Read', 'Edit', 'Delete', 'Administer', 'Contribute', 'Rename') -
Allow- Boolean value indicating whether the permission is allowed -
Deny- Boolean value indicating whether the permission is explicitly denied
-
-
Ensure [String] - Desired state of the resource:
-
'Present'- (default) Project permissions should exist -
'Absent'- Project permissions should be removed
-
-
DependsOn [String[]] - Dependencies on other resources. Use this to control the order of resource execution.
-
PsDscRunAsCredential [PSCredential] - Credentials to run this resource under.
The resource returns the following properties:
- ProjectName - The name of the project
- GroupName - The name of the group
- isInherited - Whether permissions are inherited
- Permissions - The current project-level permissions assigned
- Ensure - Current state ('Present' or 'Absent')
Configuration GrantProjectRead {
Import-DscResource -ModuleName 'AzureDevOpsDscNative'
Node localhost {
AzDoProjectPermission 'ReadersProjectAccess' {
ProjectName = 'MyProject'
GroupName = 'Readers'
isInherited = $false
Permissions = @(
@{
Permission = 'Read'
Allow = $true
}
)
Ensure = 'Present'
}
}
}
GrantProjectRead
Start-DscConfiguration -Path ./GrantProjectRead -Wait -VerboseConfiguration GrantProjectContribute {
Import-DscResource -ModuleName 'AzureDevOpsDscNative'
Node localhost {
AzDoProjectPermission 'ContributorsProjectAccess' {
ProjectName = 'MyProject'
GroupName = 'Contributors'
isInherited = $false
Permissions = @(
@{
Permission = 'Read'
Allow = $true
},
@{
Permission = 'Contribute'
Allow = $true
},
@{
Permission = 'Edit'
Allow = $true
}
)
Ensure = 'Present'
}
}
}
GrantProjectContribute
Start-DscConfiguration -Path ./GrantProjectContribute -Wait -VerboseConfiguration GrantProjectAdmin {
Import-DscResource -ModuleName 'AzureDevOpsDscNative'
Node localhost {
AzDoProjectPermission 'AdminsProjectAccess' {
ProjectName = 'MyProject'
GroupName = 'Project Administrators'
isInherited = $false
Permissions = @(
@{
Permission = 'Read'
Allow = $true
},
@{
Permission = 'Edit'
Allow = $true
},
@{
Permission = 'Delete'
Allow = $true
},
@{
Permission = 'Administer'
Allow = $true
}
)
Ensure = 'Present'
}
}
}
GrantProjectAdmin
Start-DscConfiguration -Path ./GrantProjectAdmin -Wait -VerboseConfiguration ConfigureRoleBasedProjectPermissions {
Import-DscResource -ModuleName 'AzureDevOpsDscNative'
Node localhost {
# Readers group - View-only access
AzDoProjectPermission 'ReadersAccess' {
ProjectName = 'MyProject'
GroupName = 'Readers'
isInherited = $false
Permissions = @(
@{ Permission = 'Read'; Allow = $true }
)
Ensure = 'Present'
}
# Developers group - Read and contribute
AzDoProjectPermission 'DevelopersAccess' {
ProjectName = 'MyProject'
GroupName = 'Developers'
isInherited = $false
Permissions = @(
@{ Permission = 'Read'; Allow = $true },
@{ Permission = 'Contribute'; Allow = $true },
@{ Permission = 'Edit'; Allow = $true }
)
Ensure = 'Present'
}
# Leads group - Full project access except deletion
AzDoProjectPermission 'LeadsAccess' {
ProjectName = 'MyProject'
GroupName = 'Project Leads'
isInherited = $false
Permissions = @(
@{ Permission = 'Read'; Allow = $true },
@{ Permission = 'Edit'; Allow = $true },
@{ Permission = 'Contribute'; Allow = $true },
@{ Permission = 'Rename'; Allow = $true },
@{ Permission = 'Delete'; Allow = $false }
)
Ensure = 'Present'
}
# Administrators group - Full control
AzDoProjectPermission 'AdminsAccess' {
ProjectName = 'MyProject'
GroupName = 'Project Administrators'
isInherited = $false
Permissions = @(
@{ Permission = 'Read'; Allow = $true },
@{ Permission = 'Edit'; Allow = $true },
@{ Permission = 'Delete'; Allow = $true },
@{ Permission = 'Administer'; Allow = $true }
)
Ensure = 'Present'
}
}
}
ConfigureRoleBasedProjectPermissions
Start-DscConfiguration -Path ./ConfigureRoleBasedProjectPermissions -Wait -Verbose# Get current project permissions
$properties = @{
ProjectName = 'MyProject'
GroupName = 'Developers'
}
$result = Invoke-DscResource -Name 'AzDoProjectPermission' `
-Method Get `
-Property $properties `
-ModuleName 'AzureDevOpsDscNative'
$result | Select-Object ProjectName, GroupName, isInherited, Permissions
# Set new project permissions
$setProperties = @{
ProjectName = 'MyProject'
GroupName = 'Developers'
isInherited = $false
Permissions = @(
@{ Permission = 'Read'; Allow = $true },
@{ Permission = 'Edit'; Allow = $true },
@{ Permission = 'Contribute'; Allow = $true }
)
Ensure = 'Present'
}
Invoke-DscResource -Name 'AzDoProjectPermission' `
-Method Set `
-Property $setProperties `
-ModuleName 'AzureDevOpsDscNative'Project-level permissions control access to core project features:
- Read - Allows users to view project contents, work items, and repositories
- Contribute - Allows users to contribute to the project (work items, code)
- Edit - Allows users to edit project settings and configurations
- Delete - Allows users to delete the project
- Rename - Allows users to rename the project
- Administer - Provides full administrative control over the project
- Organization-level permissions provide the baseline
- Project-level permissions override organization permissions
- Specific resource permissions (repository, pipeline, etc.) override project permissions
- Inheritance follows the principle of least privilege when properly configured
- Project-level permissions cascade to most project resources
- Repository, pipeline, and variable group permissions can override project permissions
- Area and iteration permissions are independent
- Team/group permissions may further restrict access
-
Read-Only Teams: Grant only
Readpermission -
Development Teams: Grant
Read,Contribute,Editpermissions -
Team Leads: Grant
Read,Edit,Contributepermissions -
Administrators: Grant all permissions including
Administer
Cause: The specified project does not exist in the organization.
Solution:
# Verify the project name exists
# Check Azure DevOps Projects page
# Ensure the exact project name is used (case-sensitive)Cause: The specified group does not exist in the project or organization.
Solution:
# Create the group using AzDoProjectGroup or AzDoOrganizationGroup first
# Verify the group name is correct
# Check group existence in project or organization settingsCause: Permission inheritance is affecting resource-specific permissions.
Solution:
# Set isInherited = $false for precise control
# Configure resource-specific permissions to override project permissions
# Document permission hierarchy in your configuration- AzDoProject - Create and manage projects
- AzDoProjectGroup - Manage project-level groups
- AzDoGroupPermission - Manage group permissions within projects
- AzDoGitPermission - Manage repository permissions
- AzDoPipelinePermission - Manage pipeline permissions