Use the template validation tool in Azure Stack Hub

Use the template validation tool to check whether your Azure Resource Manager templates are ready to deploy to Azure Stack Hub. The template validation tool is available in the Azure Stack Hub tools GitHub repo. Download the Azure Stack Hub tools by using the steps described in Download tools from GitHub.


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 do not 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> `

Template validation warnings or errors are displayed in the PowerShell console and written 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