Internal server error when using pickZones function in a management group deployment but scoped to subscription
- Dominant language
- Bicep
- Stars
- 3.6k
- Forks
- 830
- Avg merge
- 1d 21m
- Merged PRs (30d)
- 79
Description
**Bicep version**
Bicep CLI version 0.4.1008 (223b8d227a)
**Describe the bug**
When deploying a VM I use the pickZones logic to see if it's going to use and availability set or zones, this works just fine in isolation running 'simplePickZones.bicep'.
When I connect this up to a larger deployment at the management group
**To Reproduce**
This code works fine when deployed
New-AzDeployment -Name 'test-deployment' -Location 'UKSouth' -TemplateFile .\Bicep\simple.pickZones.bicep
simple.pickZones.bicep
```bicep
targetScope = 'subscription'
//see if availabilityzones are available
var location = 'ukwest'
var zonesAvailable = !empty(pickZones('Microsoft.Compute', 'virtualMachines', location))
output zonesAvailable bool = zonesAvailable
```
If I call that module from a main file it will return InternalServerError
New-AzManagementGroupDeployment -Name 'test-deploy-mgmtGroup' -ManagementGroupId '_idOfManagementGroup_' -Location 'UKSouth' -TemplateFile .\Bicep\main.bicep
main.bicep
```bicep
// Deployment scope
targetScope = 'managementGroup'
module picktest './simple.pickZones.bicep' = {
name: 'DP-testModule'
scope: subscription('_subscriptionId_')
params: {
}
}
output zonesAvailable bool = picktest.outputs.zonesAvailable
```
Contributor guide
Research direction
Reproduce the deployment using simple.pickZones.bicep alone, then through main.bicep at management-group scope with the subscription module scope. Start at the pickZones call and the management-group-to-subscription deployment path. Done means the nested deployment no longer returns InternalServerError and produces the zonesAvailable output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure
- Domain
- cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100