I am attempting to create an azure network with a security group applied to one of the subnets, using a Bicep template. When I deploy I get an error saying "value for reference id is missing. Path properties.subnets[1].properties.networkSecurityGroup." (Code:MissingJsonReferenceId). Below is the Bicep template.
@description('The network address for the entire network, in CIDR form')
param NetworkAddress string
@description('The network address for the subnet for Application Gateways, in CIDR form')
param AppGatewayAddress string
@description('The network address for the subnet for VM Scale Sets, in CIDR form')
param VmssAddress string
resource VMNetSecurityGroup 'Microsoft.Network/networkSecurityGroups@2021-05-01' = {
name: 'nsg-vmss'
location: resourceGroup().location
properties: {
securityRules: [
{
name: 'Deny80BetweenVms'
properties: {
description: 'Keep VMs from talking directly to one another on port 80'
access: 'Deny'
direction: 'Inbound'
protocol: '*'
sourceAddressPrefix: VmssAddress
sourcePortRange: '*'
destinationAddressPrefix: '*'
destinationPortRange: '80'
priority: 1000
}
}
]
}
}
resource Network 'Microsoft.Network/virtualNetworks@2021-05-01' = {
name: 'net1'
location: resourceGroup().location
properties: {
addressSpace: {
addressPrefixes: [
NetworkAddress
]
}
subnets: [
{
name: 'AppGatewaySubnet'
properties: {
addressPrefix: AppGatewayAddress
}
}
{
name: 'VmssSubnet'
properties: {
addressPrefix: VmssAddress
networkSecurityGroup: VMNetSecurityGroup
}
}
]
}
}