azure - 如何使用azure中的arm模板将RBAC分配给多个用户

标签 azure azure-rm-template

我有两个 AAD 应用程序(服务主体),想要使用arm模板将RBAC添加到这两个应用程序。

我尝试使用下面的arm模板进行部署。

    {
        "type": "Microsoft.Storage/storageAccounts/blobServices/containers/providers/roleAssignments",
        "apiVersion": "2018-09-01-preview",
        "name": "[concat(parameters('StorageAccountName'), '/default/',parameters('ContainerName'), '/Microsoft.Authorization/', parameters('roleNameGuid'))]",
        "properties": {
          "roleDefinitionId": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/', 'ba92f5b4-2d11-453d-a403-e96b0029c9fe')]",
          "principalId": "[parameters('principalId')]"
        }      
    },
    {
        "type": "Microsoft.Storage/storageAccounts/blobServices/containers/providers/roleAssignments",
        "apiVersion": "2018-09-01-preview",
        "name": "[concat(parameters('StorageAccountName'), '/default/',parameters('ContainerName'), '/Microsoft.Authorization/', parameters('roleNameGuid'))]",
        "properties": {
          "roleDefinitionId": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/', 'ba92f5b4-2d11-453d-a403-e96b0029c9fe')]",
          "principalId": "[parameters('principalId2')]"
        }      
    }        

当我使用此arm模板进行部署时,出现以下错误。

    Deployment template validation failed: 'The resource 'Microsoft.Storage/storageAccounts/MystorageAccounts/blobServices/default/containers/test/providers/Microsoft.Authorization/roleAssignments/aacd4b89-a70f-4be9-a0ba-6b8698dd7129' at line '52' and column '9' is defined multiple times in a template. Please see https://aka.ms/arm-template/#resources for usage details.'. (Code: InvalidTemplate)

最佳答案

您需要为资源中的 name 选项使用不同的名称。例如,您可以在名称末尾附加数字以区分差异。

关于azure - 如何使用azure中的arm模板将RBAC分配给多个用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57752021/

相关文章:

azure - 通过 ARM 模板在本地部署上使用 [deployment().properties.templateLink.uri]

azure - 使 Azure Functions 不可公开访问吗?

python - 从python中的azure blob存储读取文件

Azure 流分析 - 无输出事件

azure - 使用 ARM 模板的资源组锁定

azure-storage - 如何获取 ARM 模板中 Azure 存储帐户容器的路径

azure - 如何从 Azure 中的不同订阅和租户 ID 中提取 ACR 中可用的 docker 镜像

azure - Azure 应用服务上的 ActiveDirectoryMembershipProvider : Access Denied

azure - 无法获取 Azure 负载均衡器池的资源 ID

azure - ARM 模板 - 有条件地添加到数组