Step by Step ARM Templates - Creating ASR Template from an existing Azure Infrastructure and Modifying It@20aman Oct 24, 2016
Index of all blogs in this Step by Step ARM Templates series is located here: Step by Step Azure Resource Manager (ARM) Templates - Index
This blog post is for you if:
- You want to backup an Infrastructure configuration/setup in Azure and want to redeploy it to another environment then this blog is for you.
- You want to create similar infrastructure as one of existing deployments in Azure
- You want to modify the configurations of existing Azure IaaS infrastructure and redeploy various elements
This Power Tip is really easy if you know just the option.
- If you want to make the template for all the resources in a Resource Group in Azure, then go to the properties of the Resource Group and find the option for "Automation Script".
- If you want to get the template only for a particular resource, then navigate to that resource in the Azure Portal and then open it's settings. You will find the same "Automation Script" option.
You can check this option in the below screenshot.
Once you click on the Automation Script option in the settings (of a resource group or a resource) then you will be presented with the complete JSON template along with the JSON outline on the right side (marked 2 above in the image).
You have various options for the actions to take on the template (marked 3 in the image above):
- You can download the template
- Add to Library to deploy the same resources again and again in your subscription
- To directly deploy the resources again with the modifications you make.
Normally, you would download the template to make edits to the same. After downloading, you should start cleaning up the template. There are only 4 major tasks that you need to perform as part of the cleanup:
- Remove any hard-coded values for various dependent resources e.g. NIC for a VM, VHD for a VM etc.
- Remove any resources and dependent parameters that you don't need.
- Create Parameters for the values you want to change for each deployment and want the end user to provide during the deployment.
- Create Variables for the values which can have fixed values but are being used at multiple locations in your template.
That's all there is to it. Using this tip you can spearhead your ARM Template developments. You don't need to start from scratch and can base your templates on the existing deployments.