Coming Soon: GET:IT Endpoint Management 1-Day Conference on September 28th at 9:30 AM ET Coming Soon: GET:IT Endpoint Management 1-Day Conference on September 28th at 9:30 AM ET
Cloud Computing

Creating JSON Templates From Azure Resource Groups

This post will show you how to use the Azure portal to save JSON templates from an existing resource group.

Saving a Resource Group as a Template

It is possible to manually deploy a service into a resource group and then create a JSON template from the contents of the resource group; you can use this template as the basis for a new service, or you can create more instances of this service; for example, development, testing, production, and diagnostics.


Sponsored Content

Say Goodbye to Traditional PC Lifecycle Management

Traditional IT tools, including Microsoft SCCM, Ghost Solution Suite, and KACE, often require considerable custom configurations by T3 technicians (an expensive and often elusive IT resource) to enable management of a hybrid onsite + remote workforce. In many cases, even with the best resources, organizations are finding that these on-premise tools simply cannot support remote endpoints consistently and reliably due to infrastructure limitations.


The process for getting the JSON is very simple. Browse to the resource group in the Azure Portal and select Automation Script.

Note: The Azure Portal is constantly changing, so the names of entries in the GUI might (I should say “will”) change after we publish this article.

The JSON that will duplicate the contents of the resource group is displayed here. You can also see the Parameters JSON file, as well as the CLI, PowerShell, .NET and Ruby options for deploying the JSON template.

Viewing the JSON of a resource group [Image Credit: Aidan Finn]
Viewing the JSON of a resource group [Image Credit: Aidan Finn]
There are some interesting actions that you can perform from here:

  • Download: Get a zip file your JSON deployment. We’ll return to this later in the post.
  • Add to Library: We’ll return to this option where you can save the JSON file in Azure.
  • Deploy: You can create another copy of your service into another resource group. This option can work, but it’s messy if you do not customize the JSON template first.

Let’s save the JSON template in Azure so that we can re-use it. Click Add To Library. You are asked to name the template and add a description.

Saving an Azure resource group as a JSON template [Image Credit: Aidan Finn]
Saving an Azure resource group as a JSON template [Image Credit: Aidan Finn]
Tip: You will edit your templates over time. It’s a good idea to version your templates so that you can keep older versions and rollback if necessary.

Viewing Your Template in the Azure Portal

Any templates that you save in the Azure Portal are associated with your identity and, by default, can only be seen and used by you. Browse to Templates in the Azure Portal; here is where you will see any JSON templates that you have saved or uploaded.

Click the JSON that was just saved. The template is displayed. There are a few actions that you can do:

  • Deploy: Deploy the JSON template to a new or existing resource group.
  • Edit: Edit the template.
  • Delete: Delete the template.
  • Share: Share the template with other users/groups (ideally the latter) in your Azure AD domain.

Downloading Your Template

If you want a quick and dirty re-deployment, then the previous steps can be used to save a template and then you can deploy it without editing it. You’ll find that the template will require a lot of data to be entered as confusingly named parameters, and some items, such as load balancers (NAT and load balancing rules), could be quite complicated to deal with. The editor in the Azure Portal is OK for small tweaks, but it isn’t a great way to make larger changes. The best approach to creating a template that you want to keep is to download the original template and edit it using the free VS Code or Visual Studio.

Browse to the resource group and click the Download action. A zip file will be downloaded by your browser. You will find the following if you extract the contents of the zip file:

  • PS1: A comprehensive PowerShell script for deploying the template.
  • SH: A command-line interface script that will deploy the template.
  • rb: A Ruby script that will deploy the template.
  • CS: A C# file for deploying the template.
  • JSON: A file that you can edit to pre-program the data that will be supplied as parameters for the deployment.
  • JSON: The JSON file that describes the deployment.

The contents of a downloaded Azure JSON template zip file [Image Credit: Aidan Finn]
The contents of a downloaded Azure JSON template zip file [Image Credit: Aidan Finn]
You can edit the Template.JSON to make changes to your deployment; typically, I will:

  • Reduce the number of parameters and convert as much as possible into variables.
  • I rename parameters (easier in VS Code with the JSON extensions installed) to make it easier to understand their functions.
  • Enter new default options in parameters and sometimes restrict choices using drop-down list box.
  • Replace string values from the Resources section with reusable variables.
  • Tweak/add/remove resources as necessary.

Make sure that your Parameters.JSON is updated to match the Parameters section of the new version of Template.JSON. Then you can deploy the new version of your JSON using:

  • One of the provided scripts
  • PowerShell
  • The Azure Portal

Related Topics:


Don't have a login but want to join the conversation? Sign up for a Petri Account

Comments (0)

Leave a Reply

Aidan Finn, Microsoft Most Valuable Professional (MVP), has been working in IT since 1996. He has worked as a consultant and administrator for the likes of Innofactor Norway, Amdahl DMR, Fujitsu, Barclays and Hypo Real Estate Bank International where he dealt with large and complex IT infrastructures and MicroWarehouse Ltd. where he worked with Microsoft partners in the small/medium business space.
Live Webinar: Active Directory Security: What Needs Immediate Priority!Live on Tuesday, October 12th at 1 PM ET

Attacks on Active Directory are at an all-time high. Companies that are not taking heed are being punished, both monetarily and with loss of production.

In this webinar, you will learn:

  • How to prioritize vulnerability management
  • What attackers are leveraging to breach organizations
  • Where Active Directory security needs immediate attention
  • Overall strategy to secure your environment and keep it secured

Sponsored by: