Search code examples
azureazure-rm-templateazure-aks

How to specify different resources in a child/parent relationship in an Azure ARM template?


Trying to put together an Azure ARM template right now.

However, it seems I can create links between resources in very different ways.

Here for example: https://learn.microsoft.com/en-us/azure/templates/microsoft.network/2019-04-01/virtualnetworks

I can now specify subnets for the virtual network either under .resources or .properties.subnets.

Another way is to create another resource Microsoft.Network/virtualNetworks/subnets on its own and then add a .dependsOn key to reference the virtual network resource id.

Which is the way to go by?


Solution

  • @Mortiz When you use https://learn.microsoft.com/en-us/azure/templates/microsoft.network/2019-04-01/virtualnetworks, you are creating a new virtual network and associating subnets under that virtual network.

    On the other hand when you use Microsoft.Network/virtualNetworks/subnets, you are just creating subnets under already existing virtual network which is usually added as a .dependsOn