Test-AzDeployment

Validates a deployment.

Syntax

Test-AzDeployment
    -Location <String>
    -TemplateFile <String>
    [-SkipTemplateParameterPrompt]
    [-ApiVersion <String>]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]
Test-AzDeployment
    -Location <String>
    -TemplateParameterObject <Hashtable>
    -TemplateObject <Hashtable>
    [-SkipTemplateParameterPrompt]
    [-ApiVersion <String>]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]
Test-AzDeployment
    -Location <String>
    -TemplateParameterObject <Hashtable>
    -TemplateFile <String>
    [-SkipTemplateParameterPrompt]
    [-ApiVersion <String>]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]
Test-AzDeployment
    -Location <String>
    -TemplateParameterObject <Hashtable>
    -TemplateUri <String>
    [-SkipTemplateParameterPrompt]
    [-ApiVersion <String>]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]
Test-AzDeployment
    -Location <String>
    -TemplateParameterFile <String>
    -TemplateObject <Hashtable>
    [-SkipTemplateParameterPrompt]
    [-ApiVersion <String>]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]
Test-AzDeployment
    -Location <String>
    -TemplateParameterFile <String>
    -TemplateFile <String>
    [-SkipTemplateParameterPrompt]
    [-ApiVersion <String>]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]
Test-AzDeployment
    -Location <String>
    -TemplateParameterFile <String>
    -TemplateUri <String>
    [-SkipTemplateParameterPrompt]
    [-ApiVersion <String>]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]
Test-AzDeployment
    -Location <String>
    -TemplateParameterUri <String>
    -TemplateObject <Hashtable>
    [-SkipTemplateParameterPrompt]
    [-ApiVersion <String>]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]
Test-AzDeployment
    -Location <String>
    -TemplateParameterUri <String>
    -TemplateFile <String>
    [-SkipTemplateParameterPrompt]
    [-ApiVersion <String>]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]
Test-AzDeployment
    -Location <String>
    -TemplateParameterUri <String>
    -TemplateUri <String>
    [-SkipTemplateParameterPrompt]
    [-ApiVersion <String>]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]
Test-AzDeployment
    -Location <String>
    -TemplateObject <Hashtable>
    [-SkipTemplateParameterPrompt]
    [-ApiVersion <String>]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]
Test-AzDeployment
    -Location <String>
    -TemplateUri <String>
    [-SkipTemplateParameterPrompt]
    [-ApiVersion <String>]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

Description

The Test-AzDeployment cmdlet determines whether a deployment template and its parameter values are valid.

Examples

Example 1: Test deployment with a custom template and parameter file

PS C:\> Test-AzDeployment -Location "West US" -TemplateFile "D:\Azure\Templates\EngineeringSite.json" -TemplateParameterFile "D:\Azure\Templates\EngSiteParms.json"

This command tests a deployment at the current subscription scope using the given template file and parameters file.

Example 2: Test deployment with a custom template object and parameter file

PS C:\> $TemplateFileText = [System.IO.File]::ReadAllText("D:\Azure\Templates\EngineeringSite.json")
PS C:\> $TemplateObject = ConvertFrom-Json $TemplateFileText -AsHashtable
PS C:\> Test-AzDeployment -Location "West US" -TemplateObject $TemplateObject -TemplateParameterFile "D:\Azure\Templates\EngSiteParams.json"

This command tests a deployment at the current subscription scope using the an in-memory hashtable created from the given template file and a parameter file.

Parameters

-ApiVersion

When set, indicates the version of the resource provider API to use. If not specified, the API version is automatically determined as the latest available.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-DefaultProfile

The credentials, account, tenant, and subscription used for communication with Azure.

Type:Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Location

The location to store deployment data.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Pre

When set, indicates that the cmdlet should use pre-release API versions when automatically determining which version to use.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-SkipTemplateParameterPrompt

Skips the PowerShell dynamic parameter processing that checks if the provided template parameter contains all necessary parameters used by the template. This check would prompt the user to provide a value for the missing parameters, but providing the -SkipTemplateParameterPrompt will ignore this prompt and error out immediately if a parameter was found not to be bound in the template. For non-interactive scripts, -SkipTemplateParameterPrompt can be provided to provide a better error message in the case where not all required parameters are satisfied.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-TemplateFile

Local path to the template file.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-TemplateObject

A hash table which represents the template.

Type:Hashtable
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-TemplateParameterFile

A file that has the template parameters.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-TemplateParameterObject

A hash table which represents the parameters.

Type:Hashtable
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-TemplateParameterUri

Uri to the template parameter file.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-TemplateUri

Uri to the template file.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

Inputs

Hashtable

String

Outputs

PSResourceManagerError