Export Azure Resource Group as a JSON Template

quantum computing hero 2

In today’s Ask the Admin, I’ll show you how to export resource groups (RGs) as Azure Resource Manager (ARM) templates.

One of the great features of ARM is the ability to define how Azure resources interconnect with one another using resource groups, and deploy cloud applications, in the web-based management portal or using PowerShell, and then copy and redeploy that configuration using a declarative JSON template. If you need a primer on ARM and Azure resource groups, see Deploy VMs Using Azure Resource Manager, What is JSON and How Is It Used?, and What are Microsoft Azure resource groups? on the Petri IT Knowledgebase.

In this article, I want to show you how easy it is to copy ARM-based deployments in Azure, and either save the configuration for later use as a JSON template, or deploy a new resource group based on the configuration of an existing set of resources. For example, I have a resource group called PetriWeb that contains several VMs, public IP addresses, a virtual network, storage, and other resources that make the application work. But I need to reproduce this configuration so that I can test some proposed changes in a lab environment. Azure allows the PetriWeb resource group to be exported and redeployed with a different name using the JSON template generated during the export process.

Export a resource group

Before starting, you’ll need an Azure account. If you don’t already have one, you can sign up for a free trial here.

  • Log in to the Azure portal here.
  • In the list of options on the left of the portal window, click Resource groups.
  • In the Resource groups panel, click the resource group that you’d like to export as a JSON template.
  • In the Settings panel for the resource group, click Export template under RESOURCE MANAGEMENT.

 

Export an Azure resource group as a template (Image Credit: Russell Smith)
Export an Azure resource group as a template (Image Credit: Russell Smith)

 

Azure will now generate a JSON template based on the selected resource group.

  • In the Export resource group template panel, you can now see the generated JSON template, and there are three options of what to do with it.
  • Click Download to save a copy of the template as a .zip to your local PC.
  • Click Save template to save the template for use in your Azure subscription. In the Save template panel, enter a name and description for the template and click Save.
  • To access saved templates, click Browse in the left of the portal window and then select Templates from the list. All saved templates are then displayed in the Templates panel.

 

Exported ARM template (Image Credit: Russell Smith)
Exported ARM template (Image Credit: Russell Smith)

 

Deploy a resource group using a JSON template

You also have the option to deploy the resources defined in the template without leaving the portal GUI.

  • Click Deploy to deploy the resources defined in the template immediately.
  • The first thing you’ll need to do is provide the required values for the template parameters in the Parameters panel. The required parameter values will vary from template to template, and some values may already be prepopulated. When you’re done entering values, click OK.

 

It’s worth noting here that you may need to change some of the prepopulated values in the step above if the names given are in use elsewhere in your Azure subscription, otherwise preflight validation of the template might fail.

 

Deploying a resource group using an ARM template (Image Credit: Russell Smith)
Deploying a resource group using an ARM template (Image Credit: Russell Smith)

 

  • In the Custom deployment panel, select the Azure subscription in which to create the new resource group if you have more than one sub associated with your Microsoft account.
  • Under Resource group, check Create new and enter a name for the new resource group.
  • Select an Azure region in which to create the new resource group using the dropdown menu below Resource group location.
  • Click Review legal terms and then click Purchase at the bottom of the Purchase panel.
  • Check Pin to dashboard and click Create.

Once the deployment has completed, the new resource group will be accessible from the Azure portal dashboard, or by browsing your resource groups.

In this article, I showed you how to export Azure resource group configurations to ARM templates.