bicep
bicep copied to clipboard
Visualiser doesn't show dependencies with existing resources
Bicep version VS Code 0.4.1
Describe the bug If you have a reference to an existing resource, the visualiser doesn't show a dependency between the resources
To Reproduce
resource galleryImageVersion 'Microsoft.Compute/galleries/images/versions@2020-09-30' existing = {
name: 'gallery/image/version'
}
resource vmScaleSet 'Microsoft.Compute/virtualMachineScaleSets@2021-03-01' = {
name: 'foo'
location: resourceGroup().location
properties: {
virtualMachineProfile: {
storageProfile: {
imageReference: {
id: galleryImageVersion.id
}
}
}
}
}
Additional context If you remove the existing keyword, then the visualiser does render the dependency correctly
I think this may be due to the compiler not generating a dependsOn
for existing resources - the above compiles to:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.4.1.14562",
"templateHash": "10263985305782681691"
}
},
"functions": [],
"resources": [
{
"type": "Microsoft.Compute/virtualMachineScaleSets",
"apiVersion": "2021-03-01",
"name": "foo",
"location": "[resourceGroup().location]",
"properties": {
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"id": "[resourceId('Microsoft.Compute/galleries/images/versions', split('gallery/image/version', '/')[0], split('gallery/image/version', '/')[1], split('gallery/image/version', '/')[2])]"
}
}
}
}
}
]
}
FWIW, there is technically no dependency here. By virtue of using the existing
keyword, we assume that the resource exists and we don't need the explicit dependency. Though conceptually it makes sense to show this the same as a dependency so that it's easy to appreciate the relationship.