I am trying to create multiple RBAC roles for users/groups in a single resource.I am able to add a single group or a user to the resource but not able to provide multiple users (one with owner permission, another group/user with contributor permission) on the same resource. I came to know that "name" should be different, but when I provide a different name it says "not able to find resource.
I have declared the principalid and rolegroup as arrays. I am trying to create Azure analysis service. Below is the code. The error I am getting by running the below code is "Deployment template validation failed: 'The resource Microsoft.AnalysisServices/servers/aascmigqa/providers/Microsoft.Authorization/roleAssignments/40ba7757-1e75-5eb7-b6ca-ea5a9ca77ce3' at line '1' and column '2237' is defined multiple times in a template. Please see https://aka.ms/arm-template/#resources for usage details.'."
{
"$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()]]"
}
}
}
Is this a syntax error or something which is not possible.
Thanks in advance!