Azure / Azure/bicep

Internal server error when using pickZones function in a management group deployment but scoped to subscription

Open
#5,462 4 comments 0 reactions 0 assignees View on GitHub
intermediate language investigate
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.