Virtual Network without Address Space isn't an error
- Dominant language
- Bicep
- Stars
- 3.6k
- Forks
- 830
- Avg merge
- 1d 21m
- Merged PRs (30d)
- 79
Description
**Bicep version**
run `bicep --version` via the Bicep CLI, `az bicep version` via the AZ CLI or via VS code by navigating to the extensions tab and searching for Bicep
**Describe the bug**
Define a virtual network without an addressSpace. Bicep will not report any errors in the editor, but after submitting the template, the ARM runtime will complain:
> AddressSpace of the virtual network ... does not have any address prefixes in addressPrefixes array. AddressSpace and prefixes must be specified within properties object.
I'd expect the bicep compiler to catch this, although this looks like a provider issue as the docs don't list `AddressSpace` as being required - https://docs.microsoft.com/en-us/azure/templates/microsoft.network/virtualnetworks?tabs=bicep#virtualnetworkpropertiesformat-object .
**To Reproduce**
```bicep
resource nsg 'Microsoft.Network/networkSecurityGroups@2020-11-01' = {
name: 'superNsg'
location: resourceGroup().location
properties: {
securityRules: []
}
}
resource vnet 'Microsoft.Network/virtualNetworks@2020-06-01' = {
name: 'superVnet'
location: resourceGroup().location
properties: {
subnets: [
{
name: 'foo'
properties: {
addressPrefix: '10.0.0.0/24'
networkSecurityGroup: {
id: nsg.id
}
}
}
]
}
}
```
Contributor guide
Research direction
Start by compiling the reproduced virtual network template with the Bicep CLI, Azure CLI, or VS Code extension and compare that result with the ARM runtime error. Trace how the compiler validates Microsoft.Network/virtualNetworks properties, then add coverage so the missing address space is reported before deployment; done means the reproduction produces a compiler diagnostic.
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