Krishna
Krishna

Reputation: 3157

Azure ARM template - Handling dependencies among ARM template

I have various azure resources like Virtual network, whose template contains subnets details within that VNET, templates for Network Security Groups , associated with different subnets, Templates for Virtual Machines within each subnet. Now i have 3 different json file for template corresponding to each resource type (Subnet, NSG, VM). I want to automate this stack creation, so how should i add dependency between cross json file templtes or any other way to achieve this. Like After VNET creation--> NSG will be created --> VM's will be created

Upvotes: 0

Views: 703

Answers (3)

Falco Alexander
Falco Alexander

Reputation: 3332

I always recommend having a deep look at the the 101 of ARM templates in the very well maintained github repo:

https://github.com/Azure/azure-quickstart-templates

and a nice sort of index GUI:

There is also a nice best practices document to work through.

A nice visualization you'll here: http://armviz.io

Also be sure you do not start with a downloaded ARM template from the Azure protal of an existing solution, this leads quickly to a mess from my experience.

check the nice VS Code extensions for helping to navigate in ARM template JSONs (and if you like to vusialize like armviz.io)

Upvotes: 0

djpm
djpm

Reputation: 1

You need to look at linking or nesting the templates. When you use linked templates, you create a main template to accept parameters during deployment. The main template then references the linked templates (in your case VM, NSG and VNET) and passes values to those templates as needed. You can set dependencies between the linked template and other resources. You' find an example of this here

Upvotes: 0

DixitArora-MSFT
DixitArora-MSFT

Reputation: 1811

For example, a SQL server must exist before attempting to deploy a SQL database. You define this relationship by marking one resource as dependent on the other resource. You define a dependency with the dependsOn element, or by using the reference function.

Follow this doc which discuss about this Define the order for deploying resources in Azure Resource Manager Templates

https://learn.microsoft.com/en-us/azure/azure-resource-manager/resource-group-define-dependencies#dependson

Upvotes: 1

Related Questions