Bicep visualizer points to parent resource instead of to child resource
- Dominant language
- Bicep
- Stars
- 3.6k
- Forks
- 830
- Avg merge
- 1d 21m
- Merged PRs (30d)
- 79
Description
**Bicep version**
Bicep CLI version 0.5.6 (5f2f88f0f0)
**Describe the bug**
In network interface using subnet reference as child resource (`id: virtualNetwork::defaultSubnet.id`) visualizer points to vnet:

instead of points to the subnet as it is when using reference as a separate resource (`id: defaultSubnet`):

**To Reproduce**
Use below bicep template (it's piece of code from this [Learn module](https://docs.microsoft.com/en-us/learn/modules/migrate-azure-resources-bicep/5-exercise-refactor-bicep-file)):
main.bicep
```bicep
@description('The location into which the resources should be deployed.')
param location string = resourceGroup().location
@description('The virtual network address range.')
param virtualNetworkAddressPrefix string
@description('The default subnet address range within the virtual network')
param virtualNetworkDefaultSubnetAddressPrefix string
var virtualNetworkName = 'ToyTruck-vnet'
var virtualNetworkDefaultSubnetName = 'default'
var networkInterfaceName = 'toytruckserver237'
resource virtualNetwork 'Microsoft.Network/virtualNetworks@2020-11-01' = {
name: virtualNetworkName
location: location
properties: {
addressSpace: {
addressPrefixes: [
virtualNetworkAddressPrefix
]
}
subnets: [
{
name: virtualNetworkDefaultSubnetName
properties: {
addressPrefix: virtualNetworkDefaultSubnetAddressPrefix
privateEndpointNetworkPolicies: 'Enabled'
privateLinkServiceNetworkPolicies: 'Enabled'
}
}
]
enableDdosProtection: false
}
resource defaultSubnet 'subnets' existing = {
name: virtualNetworkDefaultSubnetName
}
}
resource networkInterface 'Microsoft.Network/networkInterfaces@2020-07-01' = {
name: networkInterfaceName
location: location
properties: {
ipConfigurations: [
{
name: 'ipconfig1'
properties: {
privateIPAllocationMethod: 'Dynamic'
subnet: {
id: virtualNetwork::defaultSubnet.id
// id: defaultSubnet
}
primary: true
privateIPAddressVersion: 'IPv4'
}
}
]
enableIPForwarding: false
}
}
resource defaultSubnet 'Microsoft.Network/virtualNetworks/subnets@2020-11-01' = {
parent: virtualNetwork
name: 'default'
properties: {
addressPrefix: '10.0.0.0/24'
delegations: []
privateEndpointNetworkPolicies: 'Enabled'
privateLinkServiceNetworkPolicies: 'Enabled'
}
}
```
Contributor guide
Research direction
Start with the main.bicep reproduction and compare the visualizer output for the virtualNetwork::defaultSubnet.id reference with the separate defaultSubnet reference. Trace how the visualizer resolves the child-resource reference; done when the first form points to the subnet rather than its parent virtual network.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure
- Domain
- cloud, devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100