Reputation: 3157
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
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
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
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
Upvotes: 1