Test-AzureResourceGroupTemplate
Test-AzureResourceGroupTemplate
Verifies a resource group template.
Syntax
Parameter Set: Deployment via Gallery and template parameters file
Test-AzureResourceGroupTemplate -GalleryTemplateIdentity <String> -ResourceGroupName <String> -TemplateParameterFile <String> [-Profile <AzureProfile> ] [-TemplateVersion <String> ] [ <CommonParameters>]
Parameter Set: Deployment via Gallery and template parameters object
Test-AzureResourceGroupTemplate -GalleryTemplateIdentity <String> -ResourceGroupName <String> -TemplateParameterObject <Hashtable> [-Profile <AzureProfile> ] [-TemplateVersion <String> ] [ <CommonParameters>]
Parameter Set: Deployment via Gallery without parameters
Test-AzureResourceGroupTemplate -GalleryTemplateIdentity <String> -ResourceGroupName <String> [-Profile <AzureProfile> ] [-TemplateVersion <String> ] [ <CommonParameters>]
Parameter Set: Deployment via template file and template parameters file
Test-AzureResourceGroupTemplate -ResourceGroupName <String> -TemplateFile <String> -TemplateParameterFile <String> [-Profile <AzureProfile> ] [-StorageAccountName <String> ] [-TemplateVersion <String> ] [ <CommonParameters>]
Parameter Set: Deployment via template file and template parameters object
Test-AzureResourceGroupTemplate -ResourceGroupName <String> -TemplateFile <String> -TemplateParameterObject <Hashtable> [-Profile <AzureProfile> ] [-StorageAccountName <String> ] [-TemplateVersion <String> ] [ <CommonParameters>]
Parameter Set: Deployment via template file without parameters
Test-AzureResourceGroupTemplate -ResourceGroupName <String> -TemplateFile <String> [-Profile <AzureProfile> ] [-StorageAccountName <String> ] [-TemplateVersion <String> ] [ <CommonParameters>]
Parameter Set: Deployment via template uri and template parameters file
Test-AzureResourceGroupTemplate -ResourceGroupName <String> -TemplateParameterFile <String> -TemplateUri <String> [-Profile <AzureProfile> ] [-TemplateVersion <String> ] [ <CommonParameters>]
Parameter Set: Deployment via template uri and template parameters object
Test-AzureResourceGroupTemplate -ResourceGroupName <String> -TemplateParameterObject <Hashtable> -TemplateUri <String> [-Profile <AzureProfile> ] [-TemplateVersion <String> ] [ <CommonParameters>]
Parameter Set: Deployment via template uri without parameters
Test-AzureResourceGroupTemplate -ResourceGroupName <String> -TemplateUri <String> [-Profile <AzureProfile> ] [-TemplateVersion <String> ] [ <CommonParameters>]
Detailed Description
The Test-AzureResourceGroupTemplate cmdlet verifies the validity of a resource group template, the template parameters, and the parameter values. This cmdlet returns errors that it finds. Otherwise, it returns no output.
For more information about Azure resources and Azure resource groups, see the New-AzureResourceGroup cmdlet.
For a complex cloud-based service, such as a web portal, you can use a resource group template. A template is a model of a resource group in JavaScript Object Notation (JSON). You can find many templates in the Azure template gallery by using the Get-AzureResourceGroupGalleryTemplate. You can also create your own templates. The templates include parameters, which are placeholders for configurable property values, likes names and sizes.
To specify a template, specify the GalleryTemplateIdentity or TemplateFile parameter. To specify template parameter values, specify the TemplateParameterFile or TemplateParameterObject parameters, or use the template parameters that are added to the command dynamically when you specify the template.
To use the dynamic parameters, include them in the command. You can type a minus sign (-) to indicate a parameter name, and then press the Tab key to cycle through the available parameters. If you omit a required template parameter, this cmdlet prompts you for the value. Template parameter values that you specify at the command line take precedence over template parameter values in a template parameter object or file.
Parameters
-GalleryTemplateIdentity<String>
Specifies the gallery template for which this cmdlet verifies validity.
Aliases |
none |
Required? |
true |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
true(ByPropertyName) |
Accept Wildcard Characters? |
false |
-Profile<AzureProfile>
Specifies the Azure profile from which this cmdlet reads. If you do not specify a profile, this cmdlet reads from the local default profile.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-ResourceGroupName<String>
Specifies the name of a resource group for which this cmdlet verifies the validity of a resource group template.
Aliases |
none |
Required? |
true |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
true(ByPropertyName) |
Accept Wildcard Characters? |
false |
-StorageAccountName<String>
Specifies the name of the storage account for which this cmdlet in which this cmdlet verifies the validity of a resource group. The default is the current storage account. If you have not selected a current storage account for your subscription, you must specify a storage account.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
true(ByPropertyName) |
Accept Wildcard Characters? |
false |
-TemplateFile<String>
Specifies the full path of a resource group template file that this cmdlet verifies.
Aliases |
none |
Required? |
true |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
true(ByPropertyName) |
Accept Wildcard Characters? |
false |
-TemplateParameterFile<String>
Specifies the full path of a file that contains template parameter values that this cmdlet verifies.
Aliases |
none |
Required? |
true |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
true(ByPropertyName) |
Accept Wildcard Characters? |
false |
-TemplateParameterObject<Hashtable>
Specifies a hash table that contains template parameter values that this cmdlet verifies.
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 file that contains template parameter values that this cmdlet verifies.
Aliases |
none |
Required? |
true |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
true(ByPropertyName) |
Accept Wildcard Characters? |
false |
-TemplateVersion<String>
Specifies the version of a template that this cmdlet verifies.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
true(ByPropertyName) |
Accept Wildcard Characters? |
false |
<CommonParameters>
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).
Inputs
The input type is the type of the objects that you can pipe to the cmdlet.
None
You can pipe input to the cmdlet by property name, but not by value.
Outputs
The output type is the type of the objects that the cmdlet emits.
Microsoft.Azure.Commands.ResourceManager.Models.PSResourceManagerError
This cmdlet returns a resource manager error, if it finds problems in in the resource group template that it verifies. If this cmdlet finds no problems, it returns no value.
Examples
Example 1: Test a custom template file
This command tests a custom template file that is named CustomHostingPlan.json. The command verifies the template and the values stored in a template parameter file that is named HostingPlanParms.json. Because the cmdlet does not find any errors, it returns no output.
Test-AzureResourceGroupTemplate -ResourceGroupName "ContosoLabsRG" -TemplateFile "D:\Documents\Azure\Templates\CustomHostingPlan.json" -TemplateParameterFile "D:\Documents\Azure\Templates\HostingPlanParms.json"
Example 2: Test parameters for a gallery template
The first command tests a gallery template and a hash table of parameter names and values. The command uses the GalleryTemplateIdentity parameter to specify the gallery template. It uses the TemplateParameterObject parameter to specify the template parameters and their values.
In this example, the template parameter hash table omits the siteLocation parameter. The cmdlet prompts you for a value. Because the command misspells subscriptionId, this command returns an error.
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'}
In the second command, the errors are corrected, and the cmdlet returns no output.
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 by using dynamic parameter values
This command tests a custom template. Instead of providing the template parameter names, this example adds the template parameters to command dynamically.
To use dynamic parameters, type a minus sign, and then press the Tab key. Windows PowerShell supplies a parameter, such as siteMode. These parameters do not follow the Windows PowerShell standard of initial uppercase letter. Enter a value, and repeat this procedure, as needed. If you omit a required template parameter, the cmdlet prompts you for the value. You can use this technique to specify all of the parameter names at the command line.
In this example, the cmdlet finds a missing parameter, hostingPlan. The cmdlet reports this error.
Test-AzureResourceGroupTemplate -ResourceGroupName "ContosoLabsRG" -TemplateFile "C:\\Documents\Azure\Templates\NewHostingPlan.json" -siteName "ContosoDev" -siteMode "Limited" -computeMode "Shared" -siteLocation "South Central US" -sku "FreeCode"