Describe the bug
Release 0.10.0 shows the following entry in the Fixes section:
- Update Resource Group roleAssignments name (GUID) to use Resource Group resourceID instead of Resource Group name
There are two problems:
- This is a Breaking Change and this is not advertised in the release notes
- This is a Breaking Change and makes it impossible to successfully run a deployment including existing Resource Groups that were first deployed with BICEPs using CARML <= 0.9.0
Looking in the repo history, this change comes from PR #2642 , which is actually marked as containing Breaking change
Regarding point 2, if you have deployed resource groups with role assignments with CARML <= 0.9.0, and you try to run a deployment again of the same BICEP with CARML 0.10.0 you get a conflict with error The role assignment already exists. and the deployment fails.
ARM is right to complain, because the assignment exists but with a different GUID as a name.
New BICEP compile versions (for sure from 0.15.31 onwards) don't complain anymore for the error shown in the ticket.
That line should be changed to something like:
useLegacyRoleAssignmentNaming ? guid(last(split(resourceId, '/')), principalId, roleDefinitionIdOrName) : guid(resourceId, principalId, roleDefinitionIdOrName)
And a useLegacyRoleAssignmentNaming param should be added to modules\Microsoft.Resources\resourceGroups.bicep\nested_roleAssignments.bicep and surfaced in modules\Microsoft.Resources\resourceGroups\deploy.bicep so that ARM can handle new deployments on existing resources deployed with old versions.
To reproduce
Deploy a Resource Group with the CARML module <= 0.9.0 and specify a Role Assignment on the Resource Group.
Update CARML to 0.10.0 and run the same deployment: it will fail with error The role assignment already exists.
Code snippet
module resourceGroups 'CARML/modules/Microsoft.Resources/resourceGroups/deploy.bicep' = {
name: '${uniqueString(deployment().name)}-ResourceGroup-test'
params: {
name: 'breaking-change-test-rg'
location: 'westeurope'
roleAssignments: [
{
principalIds: [
// ..Write here a principalId..
]
roleDefinitionIdOrName: 'Reader'
}
]
}
}
}]
Relevant log output
The role assignment already exists.
Describe the bug
Release 0.10.0 shows the following entry in the Fixes section:
There are two problems:
Looking in the repo history, this change comes from PR #2642 , which is actually marked as containing Breaking change
Regarding point 2, if you have deployed resource groups with role assignments with CARML <= 0.9.0, and you try to run a deployment again of the same BICEP with CARML 0.10.0 you get a conflict with error The role assignment already exists. and the deployment fails.
ARM is right to complain, because the assignment exists but with a different GUID as a name.
New BICEP compile versions (for sure from 0.15.31 onwards) don't complain anymore for the error shown in the ticket.
That line should be changed to something like:
useLegacyRoleAssignmentNaming ? guid(last(split(resourceId, '/')), principalId, roleDefinitionIdOrName) : guid(resourceId, principalId, roleDefinitionIdOrName)And a
useLegacyRoleAssignmentNamingparam should be added to modules\Microsoft.Resources\resourceGroups.bicep\nested_roleAssignments.bicep and surfaced in modules\Microsoft.Resources\resourceGroups\deploy.bicep so that ARM can handle new deployments on existing resources deployed with old versions.To reproduce
Deploy a Resource Group with the CARML module <= 0.9.0 and specify a Role Assignment on the Resource Group.
Update CARML to 0.10.0 and run the same deployment: it will fail with error The role assignment already exists.
Code snippet
Relevant log output