Skip to content

Management Group deployment not working with RBAC. #6832

@MattLeach25

Description

@MattLeach25

Bicep version
0.4.1318

Describe the bug
We have a template that is creating a management group, and then a module to assign RBAC at the management group level. The management group creation is fine, however when the RBAC module runs with the scope set to the management group that has just been created, it fails with the error - ManagementGroupNotFound - The management group 'EXAMPLEMG' cannot be found.

There is an implicit dependency ensuring that the management group resource is created, before the module is ran assigning the RBAC to the management group. At first we thought this may be a bug with the management group set as the scope for the RBAC module.

However, if we use a management group that already exists, everything works nicely. Therefore it looks to be an issue with the implicit dependency and it doesn't seem to be creating the management group first, before moving onto the RBAC module that should run in sequence afterwards.

To Reproduce
Steps to reproduce the behavior:

We currently have all of our templates and modules stored here > https://github.com/Azure/ResourceModules/tree/main/arm/Microsoft.Management/managementGroups
When executing the deployment with the following command, the error should appear:

Test-AzManagementGroupDeployment -TemplateParameterFile .\Microsoft.Management\managementGroups.parameters\parameters.json' -TemplateFile '.\Microsoft.Management\managementGroups\deploy.bicep' -Verbose -ManagementGroupId '<>' -Location 'WestEurope'

using the standard parameter file.

Additional details:

We do have other modules that assign RBAC at a management group level and they look identical, and work perfectly fine. However when the combination of creating the management group and then assigning RBAC at the newly created management group takes place, the error appears.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions