Azure – Define ARM templates specs (preview)

By mow you already know you can use ARM (Azure Resource Manager) templates to deploy resources on Azure in automated and consistent way.

Well, you can now define template specs, a new resource type for storing Azure template for future use.

This also allows you sharing templates with other users in your organization, fixing known issues and challenges when your templates are save in GitHub repo or storage account which requires to have public access to the repo or storage account (not really secure as you can imagine).

The new resource type is identified with Microsoft.Resources/templateSpecs.

To be able to use Azure ARM template specs you need to do the following:

  • First create your JSON file defining your template (obviously Winking smile)
  • Then create the template spec using the PowerShell command

New-AzTemplateSpec –Name <name of your spec> -Version 1.0 –ResourceGroupName <resource group to save the spec –TemplateJsonFile <path to your ARM template JSON file>

  • You can then deploy the spec using the below command

$id = “/subscriptions/<ID of your subscription>/resourceGroups/<resource group where your spec is saved>/providers/Microsoft.Resources/templateSpecs/storageSpec/versions/1.0”

New-AzResourceGroupDeployment -TemplateSpecId $id –ResourceGroupName <resource group where you deploy the spec>

or you can also get the $id using the below

$id = (Get-AzTemplateSpec –Name <name of your spec –ResourceGroupName <resource group where your template is saved> -Version 1.0).Version.Id

  • Then you just need to grant access to the resource group where you have deployed your specs to any users/groups which will use it