我正在尝试为单个资源中的用户/组创建多个 RBAC 角色。我能够将单个组或用户添加到资源,但无法提供多个用户(一个具有所有者权限,另一个组/用户具有贡献者权限)在同一资源上。我开始知道“名称”应该不同,但是当我提供不同的名称时,它会显示“无法找到资源。
我已将 principalid 和 rolegroup 声明为数组。我正在尝试创建 Azure 分析服务。下面是代码。我通过运行以下代码得到的错误是“部署模板验证失败:'资源 Microsoft.AnalysisServices/servers/aascmigqa/providers/Microsoft.Authorization/roleAssignments/40ba7757-1e75-5eb7-b6ca-ea5a9ca77ce3' 在第 1 行' 并且列 '2237' 在模板中定义了多次。有关使用详细信息,请参阅https://aka.ms/arm-template/#resources。'。
{
"$schema":"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion":"1.0.0.0",
"parameters":{
"environment":{
"type":"string",
"defaultValue":"qa",
"metadata":{
"description":"Environment name."
}
},
"subscriptionId":{
"type":"string",
"defaultValue":"xxx"
},
"location":{
"type":"string",
"defaultValue":"east us",
"metadata":{
"description":"Location of the Analysis Services."
}
},
"skuName":{
"type":"string",
"defaultValue":"S0",
"metadata":{
"description":"SKU name of the service."
}
},
"tier":{
"type":"string",
"defaultValue":"Basic",
"metadata":{
"description":"Tier name of the service"
}
},
"capacity":{
"type":"int",
"defaultValue":1,
"metadata":{
"description":"Capacity of the service"
}
},
"aasAdministrators":{
"type":"object",
"defaultValue":{
}
},
"aasTags":{
"defaultValue":{
},
"type":"Object"
},
"principalId":{
"type":"array",
"metadata":{
"description":"The principal to assign the role to"
}
},
"count": {
"type": "int",
"defaultValue": 2,
"metadata": {
"description": "Size of array"
}
},
"builtInRoleType":{
"type":"array",
"allowedValues":[
"Owner",
"Contributor",
"Reader"
],
"metadata":{
"description":"Built-in role to assign"
}
}
},
"variables":{
"server_name":"[concat('aascmig', parameters('environment'))]",
"Owner": "[concat('/subscriptions/', parameters('subscriptionId'), '/providers/Microsoft.Authorization/roleDefinitions/', '8e3af657-a8ff-443c-a75c-2fe8c4bcb635')]",
"Contributor": "[concat('/subscriptions/', parameters('subscriptionId'), '/providers/Microsoft.Authorization/roleDefinitions/', 'b24988ac-6180-42a0-ab88-20f7382dd24c')]",
"Reader": "[concat('/subscriptions/', parameters('subscriptionId'), '/providers/Microsoft.Authorization/roleDefinitions/', 'acdd72a7-3385-48ef-bd42-f606fba81ae7')]"
},
"resources":[
{
"type":"Microsoft.AnalysisServices/servers",
"apiVersion":"2017-08-01",
"name":"[variables('server_name')]",
"location":"[parameters('location')]",
"tags":"[parameters('aasTags')]",
"sku":{
"name":"[parameters('skuName')]",
"tier":"[parameters('tier')]",
"capacity":"[parameters('capacity')]"
},
"properties":{
"managedMode":1,
"asAdministrators":"[parameters('aasAdministrators')]",
"querypoolConnectionMode":"All",
"serverMonitorMode":1
}
},
{
"type": "Microsoft.AnalysisServices/servers/providers/roleAssignments",
"apiVersion": "2018-09-01-preview",
"name": "[concat(variables('server_name'), '/Microsoft.Authorization/', guid(uniqueString(variables('server_name'))))]",
"copy": {
"name": "anyname",
"count":"[length(parameters('principalId'))]"
},
"dependsOn": [
"[variables('server_name')]"
],
"properties": {
"roleDefinitionId": "[variables(parameters('builtInRoleType'))[copyIndex()]]",
"principalId": "[parameters('principalId')[copyIndex()]]"
}
}
}
这是语法错误还是不可能的事情。
提前致谢!