Cmdlets

Choose a cmdlet from the list on the left or search for a specific cmdlet. Choose a cmdlet from the list or search for a specific cmdlet.
About Help  Providers
 

Test-AzureResourceGroupTemplate

Test-AzureResourceGroupTemplate

microsoft.azure.commands.resources.dll

Synopsis

Detects errors in a resource group template or template parameters

Syntax

Test-AzureResourceGroupTemplate [-ResourceGroupName] [-TemplateFile] [-StorageAccountName] [-TemplateVersion] [<CommonParameters>]

Test-AzureResourceGroupTemplate [-ResourceGroupName] [-TemplateParameterObject] [-GalleryTemplateIdentity] [-TemplateVersion] [<CommonParameters>]

Test-AzureResourceGroupTemplate [-ResourceGroupName] [-TemplateParameterObject] [-TemplateFile] [-StorageAccountName] [-TemplateVersion] [<CommonParameters>]

Test-AzureResourceGroupTemplate [-ResourceGroupName] [-TemplateParameterObject] [-TemplateUri] [-TemplateVersion] [<CommonParameters>]

Test-AzureResourceGroupTemplate [-ResourceGroupName] [-TemplateParameterFile] [-TemplateFile] [-StorageAccountName] [-TemplateVersion] [<CommonParameters>]

Test-AzureResourceGroupTemplate [-ResourceGroupName] [-TemplateParameterFile] [-GalleryTemplateIdentity] [-TemplateVersion] [<CommonParameters>]

Test-AzureResourceGroupTemplate [-ResourceGroupName] [-TemplateParameterFile] [-TemplateUri] [-TemplateVersion] [<CommonParameters>]

Test-AzureResourceGroupTemplate [-ResourceGroupName] [-GalleryTemplateIdentity] [-TemplateVersion] [<CommonParameters>]

Test-AzureResourceGroupTemplate [-ResourceGroupName] [-TemplateUri] [-TemplateVersion] [<CommonParameters>]

Detailed Description

The Test-AzureResourceGroupTemplate cmdlet verifies the validity of a resource group template, its parameters, and parameter values. It returns errors that it finds. Otherwise, it does not return any output.To specify a template, use the GalleryTemplateIdentity or TemplateFile parameters. To specify the template parameter values, use the TemplateParameterFile or TemplateParameterObject parameters, or use the template parameters that are added to the command dynamically when you specify the template. To get the parameters, just type a minus sign (-) to indicate a parameter name and press the TAB key to trigger tab-completion. If you miss a required parameter, the cmdlet prompts you for the value. Parameter values typed at the command line take precedence over values in a template parameter object or file.A resource group template is a JSON-based model of a resource group for a complex cloud-based service, such as a web portal. You can use a resource group template to create a resource group or resource group deployment. The template includes parameter (placeholders) for configurable property values, likes names and sizes. You can find many templates in the Azure template gallery (Get-AzureResourceGroupGalleryTemplate) and you can create your own templates.

Parameters

-ResourceGroupName <String>

Specify the name of the resource group. This parameter is mandatory. Wildcards are not permitted.

Aliases

None

Required?

true

Position

named

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-TemplateFile <String>

Specifies the path and file name of a JSON template file on disk. This can be a custom template or a gallery template that is saved to disk as a JSON file, such as by using the Save-AzureResourceGroupGalleryTemplate cmdlet.To use this parameter, the subscription must include a storage account where the cmdlet can save the template. By default, this cmdlet uses the current storage account in the subscription, but you can use the StorageAccountName parameter to specify an alternate storage account. If you do not specify a storage account and the subscription does not have a storage account that is designated as "current," the command fails.To create a storage account, use the Switch-AzureMode cmdlet to switch to the Azure module, and then use the New-AzureStorageAccount cmdlet. To make the a storage account the "current storage account" for the subscription, use the CurrentStorageAccountName parameter of the Set-AzureSubscription cmdlet.

Aliases

None

Required?

true

Position

named

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-StorageAccountName <String>

Specifies the name of a storage account in the subscription. Test-AzureResourceGroupGalleryTemplate saves the contents of local template files in the storage account. This parameter is optional, but a storage account is required when you use the TemplateFile parameter.The default value is the current storage account in the subscription. If you do not specify a storage account and the subscription does not have a storage account that it designated as "current," the command fails.To create a storage account, use the Switch-AzureMode cmdlet to switch to the Azure module, and then use the New-AzureStorageAccount cmdlet. To make the a storage account the "current storage account" for the subscription, use the CurrentStorageAccountName parameter of the Set-AzureSubscription cmdlet.

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-TemplateVersion <String>

Specifies a particular version of the gallery or custom template. Enter the API version number, such as "2014-04-01-preview". This parameter is optional. If you specify this parameter, Test-AzureResourceGroupGalleryTemplate verifies that the specified template has the matching version and fails if it does not.

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-TemplateParameterObject <Hashtable>

Specifies a hash table of template parameter names and values. The parameters and values are case-sensitive. You must specify values for the template parameters, but you can use this parameter, the TemplateParameterFile parameter, or use the parameters that are added to the command dynamically when you specify the template.

Aliases

None

Required?

true

Position

named

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-GalleryTemplateIdentity <String>

Specifies the identity of the gallery template to test. Enter an Identity value not a file name. Wildcards are not permitted.To get the identity of a gallery template, use the Get-AzureResourceGroupGalleryTemplate cmdlet. To test a gallery template that is saved as a JSON file on disk, use the TemplateFile parameter.

Aliases

None

Required?

true

Position

named

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-TemplateUri <String>

Specifies the URI of a JSON template file. This file can be a custom template or a gallery template that is saved as a JSON file, such as by using the Save-AzureResourceGroupGalleryTemplate cmdlet.

Aliases

None

Required?

true

Position

named

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-TemplateParameterFile <String>

Specifies the path and name of a JSON file of template parameter names and values. You must specify values for the template parameters, but you can use this parameter, the TemplateParameterObject parameter, or use the parameters that are added to the command dynamically when you specify the template.

Aliases

None

Required?

true

Position

named

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

Input Type

None

Return Type

Microsoft.Azure.Commands.ResourceManager.Models.PSResourceManagerError

Notes

The Test-AzureResourceGroupGalleryTemplate cmdlet is included in the Azure Resource Manager module beginning in module version 0.8.0.

Examples

-------------------------- Example 1: Test a custom template file --------------------------

This command tests a custom template file, CustomHostingPlan.json, and a template parameter file, HostingPlanParms.json. Because the cmdlet does not find any errors, it does not return any output.

PS C:\>Test-AzureResourceGroupTemplate -ResourceGroupName ContosoLabsRG -TemplateFile $home\Documents\Azure\Templates\CustomHostingPlan.json -TemplateParameterFile $home\Documents\Azure\Templates\HostingPlanParms.jsonPS C:>

-------------------------- Example 2: Test a parameter object for a gallery template --------------------------

This command tests gallery template and a hash table of parameter names and values. The command uses the GalleryTemplateIdentity parameter to specify the identity of the gallery template. It uses the TemplateParameterObject cmdlet to specify the template parameters and their values.

PS C:\>Test-AzureResourceGroupTemplate -ResourceGroupName ContosoLabsRG -GalleryTemplateIdentity Microsoft.WebSite.0.1.0-preview1 -TemplateParameterObject @{siteName = "ContosoSite";hostingPlanName="ContosoHosting";siteMode="Limited";computeMode="Shared";subscriptionID='9b14a38b-4b93-4554-8bb0-3cefb47a4e1f';resourceGroup='ContosoLabsRG'}cmdlet Test-AzureResourceGroupTemplate at command pipeline position 1Supply values for the following parameters:(Type !? for Help.)siteLocation:"South Central US"Code    : InvalidTemplateMessage : Deployment template validation failed: 'The template parameters 'subscriptionID' are not valid; they are not present in the original template and can therefore not be provided at deployment time. The only supportedparameters for this template are 'siteName, hostingPlanName, siteMode, computeMode, siteLocation, subscriptionId, resourceGroup'.'.a
                       
PS C:\>Test-AzureResourceGroupTemplate -ResourceGroupName ContosoLabsRG -GalleryTemplateIdentity Microsoft.WebSite.0.1.0-preview1 -TemplateParameterObject @{siteName = "ContosoSite";hostingPlanName="ContosoHosting";siteMode="Limited";computeMode="Shared";subscriptionId='9b14a38b-4b93-4554-8bb0-3cefb47a4e1f';resourceGroup='ContosoLabsRG';siteLocation='South Central US'}

-------------------------- Example 3: Test a template with dynamic parameter values --------------------------

This command uses the Test-AzureResourceGroupTemplate cmdlet to test a custom template. Instead of providing the template parameter names, we used the feature that adds the template parameters to command dynamically.

PS C:\>Test-AzureResourceGroupTemplate -ResourceGroupName ContosoLabsRG -TemplateFile C:\Users\juneb\Documents\Azure\Templates\NewHostingPlan.json -siteName ContosoDev -siteMode Limited -computeMode Shared -siteLocation 'South Central US' -sku FreeCode    : InvalidTemplateMessage : Deployment template validation failed: 'The template parameter 'hostingPlanName' is not valid.'.

Online Version