在 Azure DevOps 中从 ARM 模板创建的新资源组的角色分配授权失败
Role assignment authorization failed for new resource group created from ARM template in Azure DevOps
使用带有 'Azure Resource Group Deployment' 任务的 Azure DevOps 发布管道从 ARM 模板创建新资源组。
ARM 模板包含在此新资源级别范围内的角色分配,例如:
{
"type": "Microsoft.Authorization/roleAssignments",
"name": "[guid(resourceGroup().id)]",
"apiVersion": "2017-05-01",
"properties": {
"roleDefinitionId": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/', '8e3af657-a8ff-443c-a75c-2fe8c4bcb635')]",
"principalId": "[parameters('rgOwnerGroupId')]",
"scope": "[resourceGroup().Id]"
}
}
由于权限错误而失败:
Authorization failed for template resource '4778ab77-xxxx-xxxx-xxxx-xxxxxxxxxxxx' of type 'Microsoft.Authorization/roleAssignments'.
The client '6ced5214-xxxx-xxxx-xxxx-xxxxxxxxxxxx' with object id '6ced5214-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
does not have permission to perform action 'Microsoft.Authorization/roleAssignments/write' at scope '/subscriptions/7a205db1-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/my-resource-group/providers/Microsoft.Authorization/roleAssignments/4778ab77-xxxx-xxxx-xxxx-xxxxxxxxxxxx'.
用户 运行 任务是 DevOps 的项目用户,似乎在新创建的资源组上具有内置贡献者角色。因此,它没有在资源组上分配角色的权限是有道理的。作为资源组的创建者,只是Contributor而不是Owner,很奇怪。虽然在我的情况下成为所有者只会对分配角色有用。
那么如何在 ARM 模板中为由同一模板创建的资源组嵌入资源组作用域角色分配?
唯一的解决方案是向 DevOps 项目用户授予更多权限吗?
您好,我刚遇到同样的问题,您需要
- 进入资源组(在你的情况下"my-resource-group")
- 为客户端 6ced5214-xxxx-xxxx-xxxx-xxxxxxxxxxxx 分配所有者或用户访问管理员的角色。
请参阅permission-authorising-release-pipeline-agains
或者使用 ARM 模板并创建 roleAssignments 任务role-assignments-template
使用带有 'Azure Resource Group Deployment' 任务的 Azure DevOps 发布管道从 ARM 模板创建新资源组。
ARM 模板包含在此新资源级别范围内的角色分配,例如:
{
"type": "Microsoft.Authorization/roleAssignments",
"name": "[guid(resourceGroup().id)]",
"apiVersion": "2017-05-01",
"properties": {
"roleDefinitionId": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/', '8e3af657-a8ff-443c-a75c-2fe8c4bcb635')]",
"principalId": "[parameters('rgOwnerGroupId')]",
"scope": "[resourceGroup().Id]"
}
}
由于权限错误而失败:
Authorization failed for template resource '4778ab77-xxxx-xxxx-xxxx-xxxxxxxxxxxx' of type 'Microsoft.Authorization/roleAssignments'. The client '6ced5214-xxxx-xxxx-xxxx-xxxxxxxxxxxx' with object id '6ced5214-xxxx-xxxx-xxxx-xxxxxxxxxxxx' does not have permission to perform action 'Microsoft.Authorization/roleAssignments/write' at scope '/subscriptions/7a205db1-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/my-resource-group/providers/Microsoft.Authorization/roleAssignments/4778ab77-xxxx-xxxx-xxxx-xxxxxxxxxxxx'.
用户 运行 任务是 DevOps 的项目用户,似乎在新创建的资源组上具有内置贡献者角色。因此,它没有在资源组上分配角色的权限是有道理的。作为资源组的创建者,只是Contributor而不是Owner,很奇怪。虽然在我的情况下成为所有者只会对分配角色有用。
那么如何在 ARM 模板中为由同一模板创建的资源组嵌入资源组作用域角色分配?
唯一的解决方案是向 DevOps 项目用户授予更多权限吗?
您好,我刚遇到同样的问题,您需要
- 进入资源组(在你的情况下"my-resource-group")
- 为客户端 6ced5214-xxxx-xxxx-xxxx-xxxxxxxxxxxx 分配所有者或用户访问管理员的角色。
请参阅permission-authorising-release-pipeline-agains
或者使用 ARM 模板并创建 roleAssignments 任务role-assignments-template