I have the following scenario.
My application registration defines a set of application roles
I dynamically deploy a scaleset with a System assigned managed identity via ARM template
During the deployment i want to assign that identity to one of the specific application role defined above
I update my deployment template with the following resource
{
"type": "Microsoft.Authorization/roleAssignments",
"apiVersion": "2017-09-01",
"name": "<random Guid>",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachineScaleSets/', '<scaleset name>')]"
],
"properties": {
"roleDefinitionId": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/', '<app role guid>')]",
"principalId": "[reference(resourceId('Microsoft.Compute/virtualMachineScaleSets', '<scaleset name>'), '2019-07-01', 'Full').Identity.principalId]",
"scope": "[resourceGroup().id]"
}
}
However the deployment fails with the following exception
The specified role definition with ID '<app role guid>' does not exist.
My assumption is that the application role definition id is no correctly formatted but i could not find any examples of this kind approle assignment in an ARM template.
Is this even possible ?