Use the template validation tool in Azure Stack Hub

Check your Azure Resource Manager templates with the template validation tool. The tool checks if your template is ready to deploy to Azure Stack Hub. You can get the validation tool from the Azure Stack Hub tools GitHub repo.


The tool validates the Azure Resource Manager template for supported resource types and API versions in Azure Stack. However, the tool doesn't validate the properties supported for each resource type.


To validate a template, you must first build a cloud capabilities file, and then run the validation tool. Use the following PowerShell modules from Azure Stack Hub tools:

  • In the CloudCapabilities folder: Az.CloudCapabilities.psm1 creates a cloud capabilities JSON file representing the services and versions in an Azure Stack Hub cloud.
  • In the TemplateValidator folder: Az.TemplateValidator.psm1 uses a cloud capabilities JSON file to test templates for deployment in Azure Stack Hub.

Build the cloud capabilities file

Before you use the template validator, run the Az.CloudCapabilities PowerShell module to build a JSON file.


If you update your integrated system, or add any new services or virtual extensions, you should run this module again.

  1. Make sure you have connectivity to Azure Stack Hub. These steps can be done from the Azure Stack Development Kit (ASDK) host, or you can use a VPN to connect from your workstation.

  2. Import the Az.CloudCapabilities PowerShell module:

    Import-Module .\CloudCapabilities\Az.CloudCapabilities.psm1
  3. Use the Get-CloudCapabilities cmdlet to retrieve service versions and create a cloud capabilities JSON file. If you don't specify -OutputPath, the file AzureCloudCapabilities.json is created in the current directory. Use your actual Azure location:

Get-AzCloudCapability -Location <your location> -Verbose

Validate templates

Use these steps to validate templates by using the Az.TemplateValidator PowerShell module. You can use your own templates, or use the Azure Stack Hub Quickstart templates.

  1. Import the Az.TemplateValidator.psm1 PowerShell module:

    cd "c:\AzureStack-Tools-az\TemplateValidator"
    Import-Module .\Az.TemplateValidator.psm1
  2. Run the template validator:

Test-AzTemplate -TemplatePath <path to template.json or template folder> `
-CapabilitiesPath <path to cloudcapabilities.json> `

The validator displays template validation warnings or errors in the PowerShell console and writes them to an HTML file in the source directory. The following screenshot is an example of a validation report:

Template validation report


The template validator cmdlet supports the following parameters.

Parameter Description Required
TemplatePath Specifies the path to recursively find Azure Resource Manager templates. Yes
TemplatePattern Specifies the name of template files to match. No
CapabilitiesPath Specifies the path to the cloud capabilities JSON file. Yes
IncludeComputeCapabilities Includes evaluation of IaaS resources, such as VM sizes and VM extensions. No
IncludeStorageCapabilities Includes evaluation of storage resources, such as SKU types. No
Report Specifies the name of the generated HTML report. No
Verbose Logs errors and warnings to the console. No


This example validates all of the Azure Stack Hub Quickstart templates downloaded to local storage. The example also validates virtual machine (VM) sizes and extensions against ASDK capabilities.

test-AzTemplate -TemplatePath C:\AzureStack-Quickstart-Templates `
-CapabilitiesPath .\TemplateValidator\AzureStackCloudCapabilities_with_AddOns_20170627.json `
-TemplatePattern MyStandardTemplateName.json `
-IncludeComputeCapabilities `
-Report TemplateReport.html

Next steps