'Is it possible with Bicep/Json to concat arrays of objects inside arrays of objects?
I have this JSON structure with parameters I use to deploy an Azure vWAN with vHubs and landingzones (VNets) in multiple regions with Azure Bicep:
{
"regions": [
{
"location": "westeurope",
"hubAddressPrefix": "10.70.0.0/16",
"landingZones": [
{
"name": "production",
"addressPrefix": "10.71.0.0/16",
"subnets": [
{
"name": "general",
"addressSpace": "10.71.1.0/24"
}
]
},
{
"name": "acceptance",
"addressPrefix": "10.77.0.0/16",
"subnets": [
{
"name": "general",
"addressSpace": "10.77.1.0/24"
}
]
},
{
"name": "test",
"addressPrefix": "10.78.0.0/16",
"subnets": [
{
"name": "general",
"addressSpace": "10.78.1.0/24"
}
]
}
]
},
{
"location": "southcentralus",
"hubAddressPrefix": "10.90.0.0/16",
"landingZones": [
{
"name": "production",
"addressPrefix": "10.91.0.0/16",
"subnets": [
{
"name": "general",
"addressSpace": "10.91.1.0/24"
}
]
},
{
"name": "acceptance",
"addressPrefix": "10.97.0.0/16",
"subnets": [
{
"name": "general",
"addressSpace": "10.97.1.0/24"
}
]
},
{
"name": "test",
"addressPrefix": "10.98.0.0/16",
"subnets": [
{
"name": "general",
"addressSpace": "10.98.1.0/24"
}
]
}
]
}
]
}
I need to concat the "landingZones" arrays in both regions. The result must be 1 array with the objects of all "landingZones" arrays, like so:
"landingZones": [
{
"name": "production",
"addressPrefix": "10.71.0.0/16",
"subnets": [
{
"name": "general",
"addressSpace": "10.71.1.0/24"
}
]
},
{
"name": "acceptance",
"addressPrefix": "10.77.0.0/16",
"subnets": [
{
"name": "general",
"addressSpace": "10.77.1.0/24"
}
]
},
{
"name": "test",
"addressPrefix": "10.78.0.0/16",
"subnets": [
{
"name": "general",
"addressSpace": "10.78.1.0/24"
}
]
},
{
"name": "production",
"addressPrefix": "10.91.0.0/16",
"subnets": [
{
"name": "general",
"addressSpace": "10.91.1.0/24"
}
]
},
{
"name": "acceptance",
"addressPrefix": "10.97.0.0/16",
"subnets": [
{
"name": "general",
"addressSpace": "10.97.1.0/24"
}
]
},
{
"name": "test",
"addressPrefix": "10.98.0.0/16",
"subnets": [
{
"name": "general",
"addressSpace": "10.98.1.0/24"
}
]
}
]
With the above concatenation I can deploy routes in the vWAN Hub routing table to route all traffic through an NVA.
I already tried to use multiple iterations (Loop-in-a-loop) but that ends up in only deploying routes for the landingzones that are processed in the last loop (overwriting the routes processed in earlier loops).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
