[Bug Report]: resources/resource-group - ResourceGroupManagedByMismatch
Describe the bug
Azure defaults ResourceGroup.managedBy as null but the ResourceModule template defaults to empty string. It is also not possible to set null with this module.
If I check if empty and send null then I get another error:
InvalidTemplate - Long running operation failed with status 'Failed'.
| Additional Info:'Deployment template validation failed: 'The template
| resource 'RG-Workday' at line '1' and column '2529' is not valid:
| Evaluation result of language expression
| '[if(empty(parameters('managedBy')), null(), parameters('managedBy'))]'
| is type 'Null', expected type is 'String'.. Please see
| https://aka.ms/arm-functions for usage details.'.
To reproduce
- Create a resource group through azure portal
- Create bicep for this resource group
module ResourceGroup '.carml/resources/resource-groups/main.bicep' = {
name: '${deployment().name}-ResourceGroup'
params: {
name: resourceGroupName
location: resourceGroupLocation
}
}
- Deploy Bicep
The managed by property of the resource group cannot be changed from its current value '<null>'
Code snippet
No response
Relevant log output
{
"code": "DeploymentFailed",
"target": "/subscriptions/***",
"message": "At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details.",
"details": [
{
"code": "ResourceGroupManagedByMismatch",
"message": "The managed by property of the resource group cannot be changed from its current value '<null>'."
}
]
}
This also happens to any Resource Group deployed using CARML modules with v <= 0.8.0, when trying to deploy again the same BICEP with CARML v >= 0.9.0: the deployment will fail.
The PR that introduced the managedBy parameter is https://github.com/Azure/ResourceModules/pull/2319 which was also erroneously marked as non-breaking change.. but as stated this breaks any existing deployment.
Any news on this?
I wonder if we should report this as a Resource Provider bug because I think the value should always be an immutable string. Alternatively, maybe there should be a ManagedResourceGroup module that separates this functionality out.
If you consume this module, I suggest removing the managedBy param.
I wonder if we should report this as a Resource Provider bug because I think the value should always be an immutable string. Alternatively, maybe there should be a ManagedResourceGroup module that separates this functionality out.
If you consume this module, I suggest removing the managedBy param.
I believe anyone using the module has been removing the managedBy param but this is a (painful) temporary workaround because it forces us to not use the stock modules: a proper fix should be available in CARML.
While I recallr reading the original issue, I didn't get around looking deeper into this. Sorry everybody, and thanks @coolhome to give it a shot. I just notified the module owner to take a look so that it's also included in AVM, and further commented on the PR. I'd hope that nullable helps us out.
Anyone know of a way to fix this without redeploying the Resource Group? I have a bunch of Resource Groups that have this issue.
Anyone know of a way to fix this without redeploying the Resource Group? I have a bunch of Resource Groups that have this issue.
That's a tough one. From the top of my head it would only come to mind to deploy 'new' resource groups and migrate all existing resources to those resource groups. :-/
Similar to @russellds ... in our case we updated core RG's some time ago and we have now discovered this issue, recreate is not an option so I assume it's now a 'live with it' or can Msft do anything on the backend?
Hey @AengusMo, for that I'd ask you to open a support ticket, as we don't have access to the backend - yet alone a customer's backend. :-/