Skip to content

Instantly share code, notes, and snippets.

@oliverlabs
Created August 8, 2023 15:27
Show Gist options
  • Save oliverlabs/ea7fae473fcb83c1e02351dc3c0779a3 to your computer and use it in GitHub Desktop.
Save oliverlabs/ea7fae473fcb83c1e02351dc3c0779a3 to your computer and use it in GitHub Desktop.
Create new virtual network subnets from an array in Bicep
var addressSpace = [
'10.0.0.0/22'
]
var subnets = [
{
name: 'test1'
subnetPrefix: '10.0.3.0/26'
}
{
name: 'test2'
subnetPrefix: '10.0.3.64/26'
}
{
name: 'test3'
subnetPrefix: '10.0.3.128/26'
}
{
name: 'test4'
subnetPrefix: '10.0.3.192/26'
}
]
resource VNET 'Microsoft.Network/virtualNetworks@2021-02-01' existing = {
name: 'ols-vnet'
}
@batchSize(1)
resource Subnets 'Microsoft.Network/virtualNetworks/subnets@2020-11-01' = [for (sn, index) in subnets: {
name: sn.name
parent: VNET
properties: {
addressPrefix: sn.subnetPrefix
}
}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment