所以我在以下方面有一些运气:
- 创建一个以所有者为范围的托管身份
resourceGroup().id
- 此身份似乎只限于客户的租户(我无法使用需要任何类型的订阅/资源访问的身份执行任何操作......有趣的是,当以发布者身份登录时我可以看到这个身份是被授予Owner
的,但是作为客户登录时什么也没透露?
- 创建第二个托管身份 - 并将 (1) 托管身份设置为
delegatedManagedIdentityResourceId
这似乎生成了一个托管身份,该身份现在范围为客户,因此第二个身份似乎能够分配给它的角色。
我仍然不完全确定我为什么需要这样做......但是现在当我将我的消费者托管身份分配给我的托管解决方案中的虚拟机时,这个虚拟机能够访问托管资源组中的所有资源。而为 VM 分配第一个托管标识给我带来了问题。
手臂
{
"type": "Microsoft.ManagedIdentity/userAssignedIdentities",
"apiVersion": "2018-11-30",
"name": "publisherMI",
"location": "[parameters('location')]"
},
{
"type": "Microsoft.Authorization/roleAssignments",
"apiVersion": "2021-04-01-preview",
"name": "[guid('bootstrapRoleAssignmentId')]",
"dependsOn": [
"[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', 'publisherMI')]"
],
"properties": {
"roleDefinitionId": "[resourceId('Microsoft.Authorization/roleDefinitions/', '8e3af657-a8ff-443c-a75c-2fe8c4bcb635')]",
"principalId": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', 'publisherMI'), '2018-11-30').principalId]",
"scope": "[resourceGroup().id]",
"principalType": "ServicePrincipal"
}
},
{
"type": "Microsoft.ManagedIdentity/userAssignedIdentities",
"apiVersion": "2018-11-30",
"name": "consumerMI",
"location": "[parameters('location')]"
},
{
"type": "Microsoft.Authorization/roleAssignments",
"apiVersion": "2021-04-01-preview",
"name": "[guid('consumerMiRoleAssignmentId')]",
"dependsOn": [
"[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', 'consumerMI')]",
"[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', 'publisherMI')]"
],
"properties": {
"roleDefinitionId": "[resourceId('Microsoft.Authorization/roleDefinitions/', '8e3af657-a8ff-443c-a75c-2fe8c4bcb635')]",
"principalId": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', 'consumerMI'), '2018-11-30').principalId]",
"scope": "[resourceGroup().id]",
"principalType": "ServicePrincipal",
"delegatedManagedIdentityResourceId" : "[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', 'publisherMI')]"
}
},