-
Bicep version Describe the bug The use-case is deploying a function app to a resource group that needs a certain role assignment on a management group to properly operate. We only found #6597 that explains that the Is this inherently impossible in ARM or "just" prevented by validation in bicep? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Bicep is reflecting an ARM limitation on what kinds of scopes can be targeted from other scopes. There is a way to work around it, but it requires two modules so that you can move from resource group scope to tenant scope, then from tenant scope to management group scope. Note that you need the main.bicep (resource group scoped) param mgName string
module tenantScoped 'tenant_scoped.bicep' = {
name: 'tenantScoped'
scope: tenant()
params: {
mgName: mgName
}
}
output mg object = tenantScoped.outputs.mg tenant_scoped.bicep targetScope = 'tenant'
param mgName string
module mgScoped 'mg_scoped.bicep' = {
name: 'mgScoped'
scope: managementGroup(mgName)
}
output mg object = mgScoped.outputs.mg mg_scoped.bicep targetScope = 'managementGroup'
output mg object = managementGroup() |
Beta Was this translation helpful? Give feedback.
-
I was wondering about the possibilities of having the underlying ARM limitation addressed (without requiring the workaround). |
Beta Was this translation helpful? Give feedback.
Bicep is reflecting an ARM limitation on what kinds of scopes can be targeted from other scopes.
There is a way to work around it, but it requires two modules so that you can move from resource group scope to tenant scope, then from tenant scope to management group scope. Note that you need the
Microsoft.Resources/deployments/write
permission on the RG, the tenant, and the MG for this to work.main.bicep (resource group scoped)
tenant_scoped.bicep