Skip to content

Instantly share code, notes, and snippets.

@johnlokerse
Created August 21, 2023 07:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnlokerse/e419e1a096ae08ea533a8b81f1bc8919 to your computer and use it in GitHub Desktop.
Save johnlokerse/e419e1a096ae08ea533a8b81f1bc8919 to your computer and use it in GitHub Desktop.
Subnetting blog
@description('The preferred IP address space for the virtual network. Add the CIDR. Default: 192.168.1.0/24')
param parAddressSpace string = '192.168.1.0/24'
@description('The preferred CIDR for the subnet. Default: 25')
param parSubnetCidr int = 25
@description('The amount of subnets to create. Default: 2')
param parAmountOfSubnets int = 2
var varSubnetCalculations = map(range(0, parAmountOfSubnets), i => {
name: 'subnet-${i}'
properties: {
addressPrefix: cidrSubnet(parAddressSpace, parSubnetCidr, i)
}
})
resource resVirtualNetwork 'microsoft.network/virtualNetworks@2019-11-01' = {
name: 'my-vnet2'
location: 'westeurope'
properties: {
addressSpace: {
addressPrefixes: [
parAddressSpace
]
}
subnets: varSubnetCalculations
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment