Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

managementGroup() function doesn't seem to work for parent property #2535

Closed
johndowns opened this issue May 6, 2021 · 9 comments · Fixed by #4478
Closed

managementGroup() function doesn't seem to work for parent property #2535

johndowns opened this issue May 6, 2021 · 9 comments · Fixed by #4478
Assignees
Labels
bug Something isn't working top 10 committed
Milestone

Comments

@johndowns
Copy link
Contributor

Bicep version
Bicep CLI version 0.3.439 (fecce96)

Describe the bug
I've just been testing creating MGs in the nightly builds, and it didn't behave the way I expected. Here's my Bicep file:

targetScope = 'managementGroup'

resource mg 'Microsoft.Management/managementGroups@2020-05-01' = {
  name: 'MyChildMG'
  scope: tenant()
  properties: {
    displayName: 'This should be a child of MyParentMG'
    details: {
       parent: managementGroup()
    }
  }
}

When I deployed this, I used this CLI command:

az deployment mg create -m MyParentMG ...

I expected that the template would create the MG as a child MG of MyParentMG, but it created it directly under the tenant root MG. It's like the parent: managementGroup() line was ignored.

When I looked at the JSON emitted by Bicep, the parent property has been given the value [createObject()] - which which definitely looks wrong to me.

Should this work, or am I doing this the wrong way?

To Reproduce
Steps to reproduce the behavior:

Additional context
Add any other context about the problem here.

@ghost ghost added the Needs: Triage 🔍 label May 6, 2021
@johndowns
Copy link
Contributor Author

@majastrz Tagging you since you were looking at #1691 recently.

@johndowns johndowns changed the title managementGroup() scope function doesn't seem to work managementGroup() function doesn't seem to work for parent property May 6, 2021
@majastrz
Copy link
Member

majastrz commented May 6, 2021

This is a good find. Many of our scope functions don't really exist in the runtime (we have a plan to add them), so we currently compile them to an empty object when they are used outside of the scope property.

@johndowns
Copy link
Contributor Author

@majastrz OK cool. So if I wanted to do something like the above, is there a way to do this today (in the nightly builds)? I'm trying to avoid having to embed the management group ID within the template, and would prefer to look it up dynamically - but if that's not possible then I'll work around it.

@majastrz
Copy link
Member

majastrz commented May 6, 2021

I can't think of any way to do this. @bmoore-msft Do you know any way to get the current MG's name or fully qualified resource ID inside an MG-scoped deployment without explicitly passing it in?

@bmoore-msft
Copy link
Contributor

Not until 4451578 is merged...

@majastrz
Copy link
Member

majastrz commented May 6, 2021

@johndowns, that's an internal work item to add the managementGroup() function to the runtime.

@alex-frankel alex-frankel added bug Something isn't working and removed Needs: Triage 🔍 labels May 6, 2021
@alex-frankel
Copy link
Collaborator

Related to #947

@alex-frankel alex-frankel added this to the v0.5 milestone May 13, 2021
@slapointe
Copy link
Contributor

slapointe commented Jun 3, 2021

This will resolves a lot of scoping issues. Can't wait for 4451578 :D

Will all these scenarios be supported as parent for a management group ?

  • Resource (mg)
  • managementGroup()
  • managementGroup('parent')
  • tenant()

@anthony-c-martin
Copy link
Member

Waiting on intermediate language change - check back on 8/31

@anthony-c-martin anthony-c-martin self-assigned this Sep 17, 2021
@ghost ghost locked as resolved and limited conversation to collaborators May 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working top 10 committed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants