我正在尝试通过 ARM 模板将服务总线接收器角色添加到用户分配的托管标识。
这是模板
// User Assigned Managed Identity
{
"type": "Microsoft.ManagedIdentity/userAssignedIdentities",
"apiVersion": "2018-11-30",
"name": "MyManagedIdentity",
"location": "[resourceGroup().location]",
},
// User Assigned Managed Identity Role
{
"type": "Microsoft.Authorization/roleAssignments",
"apiVersion": "2020-04-01-preview",
"name": "[guid(resourceGroup().id)]",
"dependsOn": [
"[resourceID('Microsoft.ManagedIdentity/userAssignedIdentities/','MyManagedIdentity')]"
],
"properties": {
"roleDefinitionId": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleDefinitions/090c5cfd-751d-490a-894a-3ce6f1109419",
"principalId": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', 'MyManagedIdentity'), '2018-11-30').principalId]",
}
},
它返回此错误。
状态消息:不允许更新租户 ID、应用程序 ID、主体 ID 和范围。(代码:RoleAssignmentUpdateNotPermitted)
我不确定出了什么问题。
principalId 应该来自我认为的托管身份。以及来自服务总线角色 id 的 roleDefinitionId。