简体   繁体   English

无法使用 ARM 模板创建 Azure RBAC 自定义角色

[英]Cannot create Azure RBAC custom role using ARM Template

I am unable to spin up Azure RBAC Roles using ARM templates.我无法使用 ARM 模板启动 Azure RBAC 角色。 As per my template the parameter "actions" would be of type Array.根据我的模板,参数“actions”将是 Array 类型。 It passes Validation but gives error during runtime.它通过了验证,但在运行时给出了错误。 It runs fine however when I am using type String, passing one single action item as parameter.但是,当我使用 String 类型时,它运行良好,将单个操作项作为参数传递。

{
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
    "roleName": {
        "type": "string"
    },
    "description": {
        "type": "string"
    },
    "rbacGuid": {
        "type": "string"
    },
    "actions": {
        "type": "Array"
    }
},
"variables": {
},
"resources": [
    {
        "type": "Microsoft.Authorization/roleDefinitions",
        "apiVersion": "2017-05-01",
        "name": "[parameters('rbacGuid')]",
        "properties": {
            "roleName": "[parameters('roleName')]",
            "IsCustom": true,
            "Description": "[parameters('description')]",
            "permissions": [
                {
                    "Actions": [
                        "[parameters('actions')]"

                    ],
                    "NotActions": []
                }
            ],
            "AssignableScopes": [
                "[subscription().id]"
            ]
        }
    }
],
"outputs": {        
}

} }

Error I got:我得到的错误:

az deployment sub create --location $location --template-file $templa ...

  + CategoryInfo          : NotSpecified: (Deployment fail...0cea05be18f1. {:String) [], RemoteException
  + FullyQualifiedErrorId : NativeCommandError

"error": {
  "code": "InvalidRequestContent",
  "message": "The content of your request was not valid, and the original object could not be deserialized. Exception message: 'Unexpected character encountered while 

parsing value: [.解析值:[. Path 'properties.permissions[0].Actions', line 1, position 160.'" } }路径 'properties.permissions[0].Actions',第 1 行,position 160.'" } }

You need to change this你需要改变这个

                    "Actions": [
                        "[parameters('actions')]"

                    ],

And make it并做到


            "Actions": "[parameters('actions')]",

See full example:查看完整示例:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ARM 模板 - 设置对现有 RBAC 角色的依赖 - ARM Template - Set dependency on RBAC Role existing 如何在Azure中使用Arm模板将RBAC分配给多个用户 - How to assign RBAC to multiple user using arm template in azure 使用Azure RBAC的角色管理 - Role Management using Azure RBAC 使用 ARM 将 Azure RBAC 应用到资源 - Apply Azure RBAC to a resource using ARM 无法使用 ARM 模板创建带有 ip 的 azure 私有 dns A 记录 - Cannot create azure private dns A record with its ip by using ARM template 我无法使用 Privileged Identity Management 管理 Azure 资源上的 RBAC 角色 - I cannot manage a RBAC role on a Azure resource with Privileged Identity Management 是否可以通过 Microsoft Graph 创建 Azure RBAC 角色 - Is it possible to create Azure RBAC role via Microsoft Graph 如何使用 azure arm 模板创建 azure webjob? - How to create azure webjob using azure arm template? Azure 存储 blob 容器使用 ARM 分配 RBAC - Azure Storage blob container assign RBAC using ARM 如何在 Azure 中创建自定义角色,以便其他用户只能查看 blob 容器中的文件列表,但不能查看其内容(RBAC) - How to create a custom role in Azure, so that another user is able to only view the list of files in a blob container but not its contents(RBAC)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM