Skip to content

[Bug Report]: resources/resource-group - ResourceGroupManagedByMismatch #3386

Closed

Description

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.

image

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

  1. Create a resource group through azure portal
  2. Create bicep for this resource group
module ResourceGroup '.carml/resources/resource-groups/main.bicep' = {
  name: '${deployment().name}-ResourceGroup'
  params: {
    name: resourceGroupName
    location: resourceGroupLocation
  }
}
  1. 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>'."
    }
  ]
}

Activity

  1. zydio commented on Jul 25, 2023

    @zydio

    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 #2319 which was also erroneously marked as non-breaking change.. but as stated this breaks any existing deployment.

  2. adnkai commented on Aug 29, 2023

    @adnkai

    Any news on this?

  3. coolhome commented on Sep 11, 2023

    @coolhome
    ContributorAuthor

    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.

  4. zydio commented on Sep 12, 2023

    @zydio

    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.

  5. AlexanderSehr commented on Dec 10, 2023

    @AlexanderSehr
    Contributor

    While I recallr reading the original issue, I didn't get around looking deeper into this. Sorry everybody, and thanks Preston Alvarado (@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.

  6. moved this from Needs triage to Closed in Bug boardon Dec 14, 2023
  7. russellds commented on May 29, 2024

    @russellds

    Anyone know of a way to fix this without redeploying the Resource Group? I have a bunch of Resource Groups that have this issue.

  8. AlexanderSehr commented on Jun 1, 2024

    @AlexanderSehr
    Contributor

    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. :-/

  9. AengusMo commented on Jun 6, 2024

    @AengusMo

    Similar to Russell Slater (@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?

  10. AlexanderSehr commented on Jun 6, 2024

    @AlexanderSehr
    Contributor

    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. :-/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

  • Status
    Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions