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

问题描述 投票:0回答:1

我无法使用ARM模板启动Azure RBAC角色。根据我的模板,参数“ actions”将为Array类型。它通过了验证,但在运行时给出了错误。但是,当我使用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": {        
}

}

我得到的错误:

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 

解析值:[。路径'properties.permissions [0] .Actions,第1行,位置160。'“}}

azure rbac
1个回答
0
投票

您需要更改此设置

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

                    ],

并使其


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

查看完整示例:

© www.soinside.com 2019 - 2024. All rights reserved.