I use a bicep script to create a virtual network and 3 subnets
param vnetName string = 'vnet'
@description('The IP address range for virtual network')
param vnetAddressPrefix string = '10.201.0.0/16' //This value cannot be changed as it is used for deploying a containerApp
param subnetname string = 'subnet-app'
@description('The IP address space used for app subnet.')
param appSubnetAddressPrefix string = '10.201.0.0/23' //this subnet range cannot be changed as used for deploying containerApp
param privatesubnet string = 'subnet-pe'
@description('The IP address space used ')
param privatesubnetaddressprefix string = '10.201.1.0/23'
param assetsubnet string = 'subnnet-assets'
@description('The IP address space used for subnet asset.')
param assetsnet string = '10.201.2.0/23'
When i run the bicep file which should create 1 Virtual network and 3 subnets i get this
error.
"code": "InvalidTemplateDeployment", "message": "The template deployment 'exdeploy' is not valid according to the validation procedure. The tracking id is 'adfd-1e75eedfd40fa-32343-dderese1232'. See inner errors for details."}
Inner Errors:
{"code": "InvalidCIDRNotation", "target": "/subscriptions/dysd/resourceGroups/mygrp/providers/Microsoft.Network/virtualNetworks/vnet-edersede", "message": "The address prefix 10.201.1.0/23 in resource /subscriptions/dysd/resourceGroups/mygrp/providers/Microsoft.Network/virtualNetworks/vnet-edersede/subnets/subnet-pe has an invalid CIDR notation. For the given prefix length, the address prefix should be 10.201.0.0/23."}
No resource gets created
Can anyone help here? Thanks
2
Answers
I created Bicep file in My Local and the below code is filled in this file.
Result :
Use any CIDR calculator(example).
10.201.0.0/23 has a starting IP of 10.201.0.0 and ending IP of 10.201.1.255. So your subnet 2 of 10.201.1.0/23 is actually overlapping subnet 1.
You can configure the following non-overlapping CIDRs for your subnets. This will work.
Subnet 1 : 10.201.0.0/23
Subnet 2 : 10.201.2.0/23
Subnet 3 : 10.201.4.0/23