This quickstart shows you how to package an Azure Resource Manager template (ARM template) into a template spec. Then, you deploy that template spec. Your template spec contains an ARM template that deploys a storage account.
You create a template spec from a local template. Copy the following template and save it locally to a file named azuredeploy.json. This quickstart assumes you've saved to a path c:\Templates\azuredeploy.json but you can use any path.
The template spec is a resource type named Microsoft.Resources/templateSpecs. To create a template spec, use PowerShell, Azure CLI, the portal, or an ARM template.
Search for template specs. Select Template specs from the available options.
Select Import template.
Select the folder icon.
Navigate to the local template you saved and select it. Select Open.
Select Import.
Provide the following values:
Name: enter a name for the template spec. For example, storageSpec
Subscription: select an Azure subscription used for creating the template spec.
Resource Group: select Create new, and then enter a new resource group name. For example, templateSpecRG.
Location: select a location for the resource group. For example, West US 2.
Version: enter a version for the template spec. Use 1.0.
Select Review + Create.
Select Create.
Note
Instead of using an ARM template, we recommend that you use PowerShell or CLI to create your template spec. Those tools automatically convert linked templates to artifacts connected to your main template. When you use an ARM template to create the template spec, you must manually add those linked templates as artifacts, which can be complicated.
When you use an ARM template to create the template spec, the template is embedded in the resource definition. There are some changes you need to make to your local template. Copy the following template and save it locally as azuredeploy.json.
Note
In the embedded template, all template expressions must be escaped with a second left bracket. Use "[[ instead of "[. JSON arrays still use a single left bracket.
az deployment group create \
--resource-group templateSpecRG \
--template-file "c:\Templates\azuredeploy.json"
Deploy template spec
To deploy a template spec, use the same deployment commands as you would use to deploy a template. Pass in the resource ID of the template spec to deploy.
az deployment group create \
--resource-group storageRG \
--template-file "c:\Templates\storage.json"
Grant access
If you want to let other users in your organization deploy your template spec, you need to grant them read access. You can assign the Reader role to a Microsoft Entra group for the resource group that contains template specs you want to share. For more information, see Tutorial: Grant a group access to Azure resources using Azure PowerShell.
Update template
Let's suppose you've identified a change you want to make to the template in your template spec. The following template is similar to your earlier template except it adds a prefix for the storage account name. Copy the following template and update your azuredeploy.json file.
Rather than creating a new template spec for the revised template, add a new version named 2.0 to the existing template spec. Users can choose either version to deploy.
Deploy that version. Provide a prefix for the storage account name.
az deployment group create \
--resource-group storageRG \
--template-spec $id \
--parameters namePrefix='demoaccount'
In your template spec, select Create new version.
Name the new version 2.0 and optionally add notes. Select Edit template.
Replace the contents of the template with your updated template. Select Review + Save.
Select Save changes.
To deploy the new version, select Versions
For the version you want to deploy, select the three dots and Deploy.
Fill in the fields as you did when deploying the earlier version.
Select Review + create.
Select Create.
Again, you must make some changes to your local template to make it work with template specs. Copy the following template and save it locally as azuredeploy.json.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see: https://aka.ms/ContentUserFeedback.