-
Notifications
You must be signed in to change notification settings - Fork 0
AzDoServiceConnectionPermission
The AzDoServiceConnectionPermission DSC resource is used to manage role-based permissions for service connections (service endpoints) in Azure DevOps. It allows you to control which groups and users can use, edit, or manage service connections for authentication with external services and platforms.
AzDoServiceConnectionPermission [string] #ResourceName
{
ProjectName = [String] $ProjectName
ConnectionName = [String] $ConnectionName
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.
-
ConnectionName [String] - The name of the service connection.
-
GroupName [String] - The name of the group whose permissions are being managed.
-
isInherited [Boolean] - Whether permissions are inherited from the project level. Default is
$true. -
Permissions [HashTable[]] - An array of permission hashtables, each containing:
-
Permission- The permission name (e.g., 'Use', 'Edit', 'Delete', 'Manage') -
Allow- Boolean indicating if permission is allowed -
Deny- Boolean indicating if permission is denied
-
-
Ensure [String] - Desired state of the resource:
-
'Present'- (default) Permissions should be configured -
'Absent'- 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
- ConnectionName - The name of the service connection
- GroupName - The name of the group
- isInherited - Whether permissions are inherited
- Permissions - The configured permissions
- Ensure - Current state ('Present' or 'Absent')
Configuration GrantServiceConnectionAccess {
Import-DscResource -ModuleName 'AzureDevOpsDscNative'
Node localhost {
AzDoServiceConnectionPermission 'AzureDevAccess' {
ProjectName = 'MyProject'
ConnectionName = 'Azure Dev Subscription'
GroupName = 'Development Team'
isInherited = $false
Permissions = @(
@{
Permission = 'Use'
Allow = $true
},
@{
Permission = 'Edit'
Allow = $false
}
)
Ensure = 'Present'
}
}
}
GrantServiceConnectionAccess
Start-DscConfiguration -Path ./GrantServiceConnectionAccess -Wait -VerboseConfiguration RestrictProductionConnection {
Import-DscResource -ModuleName 'AzureDevOpsDscNative'
Node localhost {
AzDoServiceConnectionPermission 'ProdAccess' {
ProjectName = 'MyProject'
ConnectionName = 'Azure Production Subscription'
GroupName = 'DevOps Team'
isInherited = $false
Permissions = @(
@{ Permission = 'Use'; Allow = $true },
@{ Permission = 'Edit'; Allow = $true }
)
Ensure = 'Present'
}
AzDoServiceConnectionPermission 'DeveloperRestriction' {
ProjectName = 'MyProject'
ConnectionName = 'Azure Production Subscription'
GroupName = 'Developers'
isInherited = $false
Permissions = @(
@{ Permission = 'Use'; Allow = $false; Deny = $true }
)
Ensure = 'Present'
}
}
}
RestrictProductionConnection
Start-DscConfiguration -Path ./RestrictProductionConnection -Wait -VerboseConfiguration MultiServiceConnections {
Import-DscResource -ModuleName 'AzureDevOpsDscNative'
Node localhost {
AzDoServiceConnectionPermission 'DevAzure' {
ProjectName = 'MyProject'
ConnectionName = 'Azure Dev'
GroupName = 'Developers'
isInherited = $false
Permissions = @(
@{ Permission = 'Use'; Allow = $true },
@{ Permission = 'Edit'; Allow = $true }
)
Ensure = 'Present'
}
AzDoServiceConnectionPermission 'AWS' {
ProjectName = 'MyProject'
ConnectionName = 'AWS Deployment'
GroupName = 'DevOps Team'
isInherited = $false
Permissions = @(
@{ Permission = 'Use'; Allow = $true },
@{ Permission = 'Edit'; Allow = $true }
)
Ensure = 'Present'
}
AzDoServiceConnectionPermission 'DockerHub' {
ProjectName = 'MyProject'
ConnectionName = 'Docker Hub Registry'
GroupName = 'Developers'
isInherited = $false
Permissions = @(
@{ Permission = 'Use'; Allow = $true }
)
Ensure = 'Present'
}
}
}
MultiServiceConnections
Start-DscConfiguration -Path ./MultiServiceConnections -Wait -Verbose# Get the current state of service connection permissions
$properties = @{
ProjectName = 'MyProject'
ConnectionName = 'Azure Dev Subscription'
GroupName = 'Development Team'
}
$result = Invoke-DscResource -Name 'AzDoServiceConnectionPermission' `
-Method Get `
-Property $properties `
-ModuleName 'AzureDevOpsDscNative'
$result | Select-Object ProjectName, ConnectionName, GroupName, isInherited, PermissionsConfiguration AllowPipelineServiceAccess {
Import-DscResource -ModuleName 'AzureDevOpsDscNative'
Node localhost {
AzDoServiceConnectionPermission 'PipelineAzureAccess' {
ProjectName = 'MyProject'
ConnectionName = 'Azure Dev Subscription'
GroupName = 'Pipeline Service'
isInherited = $false
Permissions = @(
@{ Permission = 'Use'; Allow = $true }
)
Ensure = 'Present'
}
}
}
AllowPipelineServiceAccess
Start-DscConfiguration -Path ./AllowPipelineServiceAccess -Wait -Verbose- Use - Ability to use the service connection in pipelines
- Edit - Ability to modify the service connection credentials/configuration
- Delete - Ability to delete the service connection
- Manage - Ability to manage service connection permissions
- Azure subscriptions, AWS, Docker registries, GitHub, npm feeds, etc.
- Different connection types may have different permission models
- Security should be a priority for cloud connection permissions
- Use the principle of least privilege for permissions
- Restrict edit permissions to connection owners only
- Create separate connections for dev, staging, and production
- Regularly audit who has access to critical connections
- Document which pipelines use each connection
- When
isInheritedis$true, permissions flow from project settings - Setting
isInheritedto$falseallows custom permissions - Important for restricting production connections
Cause: The service connection does not exist
Solution:
# Create the service connection first using AzDoServiceConnection resource
# Verify connection name matches exactly (case-sensitive)Cause: Group does not exist or insufficient permissions
Solution:
- Verify the group exists in the project
- Ensure user has service connection admin permissions
- Check personal access token has correct scope
Cause: Pipelines lack "Use" permission
Solution:
- Grant "Use" permission to pipeline service accounts
- Verify pipelines have access to the connection
- Check project pipeline service connection permissions
- AzDoServiceConnection - Create and manage service connections
- AzDoProjectPermission - Manage project-level permissions
- AzDoGroupPermission - Manage group permissions
- AzDoPipeline - Create pipelines that use service connections