Edit

Share via


Test-AzResourceGroupDeployment

Validates a resource group deployment.

Syntax

ByTemplateFileWithNoParameters (Default)

Test-AzResourceGroupDeployment
    -ResourceGroupName <String>
    -TemplateFile <String>
    [-Mode <DeploymentMode>]
    [-RollbackToLastDeployment]
    [-RollBackDeploymentName <String>]
    [-QueryString <String>]
    [-ValidationLevel <String>]
    [-SuppressDiagnostics]
    [-SkipTemplateParameterPrompt]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

ByTemplateObjectAndParameterObject

Test-AzResourceGroupDeployment
    -ResourceGroupName <String>
    -TemplateParameterObject <Hashtable>
    -TemplateObject <Hashtable>
    [-Mode <DeploymentMode>]
    [-RollbackToLastDeployment]
    [-RollBackDeploymentName <String>]
    [-QueryString <String>]
    [-ValidationLevel <String>]
    [-SuppressDiagnostics]
    [-SkipTemplateParameterPrompt]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

ByTemplateFileAndParameterObject

Test-AzResourceGroupDeployment
    -ResourceGroupName <String>
    -TemplateParameterObject <Hashtable>
    -TemplateFile <String>
    [-Mode <DeploymentMode>]
    [-RollbackToLastDeployment]
    [-RollBackDeploymentName <String>]
    [-QueryString <String>]
    [-ValidationLevel <String>]
    [-SuppressDiagnostics]
    [-SkipTemplateParameterPrompt]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

ByTemplateUriAndParameterObject

Test-AzResourceGroupDeployment
    -ResourceGroupName <String>
    -TemplateParameterObject <Hashtable>
    -TemplateUri <String>
    [-Mode <DeploymentMode>]
    [-RollbackToLastDeployment]
    [-RollBackDeploymentName <String>]
    [-QueryString <String>]
    [-ValidationLevel <String>]
    [-SuppressDiagnostics]
    [-SkipTemplateParameterPrompt]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

ByTemplateSpecResourceIdAndParamsObject

Test-AzResourceGroupDeployment
    -ResourceGroupName <String>
    -TemplateParameterObject <Hashtable>
    -TemplateSpecId <String>
    [-Mode <DeploymentMode>]
    [-RollbackToLastDeployment]
    [-RollBackDeploymentName <String>]
    [-QueryString <String>]
    [-ValidationLevel <String>]
    [-SuppressDiagnostics]
    [-SkipTemplateParameterPrompt]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

ByTemplateObjectAndParameterFile

Test-AzResourceGroupDeployment
    -ResourceGroupName <String>
    -TemplateParameterFile <String>
    -TemplateObject <Hashtable>
    [-Mode <DeploymentMode>]
    [-RollbackToLastDeployment]
    [-RollBackDeploymentName <String>]
    [-QueryString <String>]
    [-ValidationLevel <String>]
    [-SuppressDiagnostics]
    [-SkipTemplateParameterPrompt]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

ByTemplateFileAndParameterFile

Test-AzResourceGroupDeployment
    -ResourceGroupName <String>
    -TemplateParameterFile <String>
    -TemplateFile <String>
    [-Mode <DeploymentMode>]
    [-RollbackToLastDeployment]
    [-RollBackDeploymentName <String>]
    [-QueryString <String>]
    [-ValidationLevel <String>]
    [-SuppressDiagnostics]
    [-SkipTemplateParameterPrompt]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

ByTemplateUriAndParameterFile

Test-AzResourceGroupDeployment
    -ResourceGroupName <String>
    -TemplateParameterFile <String>
    -TemplateUri <String>
    [-Mode <DeploymentMode>]
    [-RollbackToLastDeployment]
    [-RollBackDeploymentName <String>]
    [-QueryString <String>]
    [-ValidationLevel <String>]
    [-SuppressDiagnostics]
    [-SkipTemplateParameterPrompt]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

ByTemplateSpecResourceIdAndParams

Test-AzResourceGroupDeployment
    -ResourceGroupName <String>
    -TemplateParameterFile <String>
    -TemplateSpecId <String>
    [-Mode <DeploymentMode>]
    [-RollbackToLastDeployment]
    [-RollBackDeploymentName <String>]
    [-QueryString <String>]
    [-ValidationLevel <String>]
    [-SuppressDiagnostics]
    [-SkipTemplateParameterPrompt]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

ByParameterFileWithNoTemplate

Test-AzResourceGroupDeployment
    -ResourceGroupName <String>
    -TemplateParameterFile <String>
    [-Mode <DeploymentMode>]
    [-RollbackToLastDeployment]
    [-RollBackDeploymentName <String>]
    [-QueryString <String>]
    [-ValidationLevel <String>]
    [-SuppressDiagnostics]
    [-SkipTemplateParameterPrompt]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

ByTemplateObjectAndParameterUri

Test-AzResourceGroupDeployment
    -ResourceGroupName <String>
    -TemplateParameterUri <String>
    -TemplateObject <Hashtable>
    [-Mode <DeploymentMode>]
    [-RollbackToLastDeployment]
    [-RollBackDeploymentName <String>]
    [-QueryString <String>]
    [-ValidationLevel <String>]
    [-SuppressDiagnostics]
    [-SkipTemplateParameterPrompt]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

ByTemplateFileAndParameterUri

Test-AzResourceGroupDeployment
    -ResourceGroupName <String>
    -TemplateParameterUri <String>
    -TemplateFile <String>
    [-Mode <DeploymentMode>]
    [-RollbackToLastDeployment]
    [-RollBackDeploymentName <String>]
    [-QueryString <String>]
    [-ValidationLevel <String>]
    [-SuppressDiagnostics]
    [-SkipTemplateParameterPrompt]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

ByTemplateUriAndParameterUri

Test-AzResourceGroupDeployment
    -ResourceGroupName <String>
    -TemplateParameterUri <String>
    -TemplateUri <String>
    [-Mode <DeploymentMode>]
    [-RollbackToLastDeployment]
    [-RollBackDeploymentName <String>]
    [-QueryString <String>]
    [-ValidationLevel <String>]
    [-SuppressDiagnostics]
    [-SkipTemplateParameterPrompt]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

ByTemplateSpecResourceIdAndParamsUri

Test-AzResourceGroupDeployment
    -ResourceGroupName <String>
    -TemplateParameterUri <String>
    -TemplateSpecId <String>
    [-Mode <DeploymentMode>]
    [-RollbackToLastDeployment]
    [-RollBackDeploymentName <String>]
    [-QueryString <String>]
    [-ValidationLevel <String>]
    [-SuppressDiagnostics]
    [-SkipTemplateParameterPrompt]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

ByTemplateObjectWithNoParameters

Test-AzResourceGroupDeployment
    -ResourceGroupName <String>
    -TemplateObject <Hashtable>
    [-Mode <DeploymentMode>]
    [-RollbackToLastDeployment]
    [-RollBackDeploymentName <String>]
    [-QueryString <String>]
    [-ValidationLevel <String>]
    [-SuppressDiagnostics]
    [-SkipTemplateParameterPrompt]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

ByTemplateUriWithNoParameters

Test-AzResourceGroupDeployment
    -ResourceGroupName <String>
    -TemplateUri <String>
    [-Mode <DeploymentMode>]
    [-RollbackToLastDeployment]
    [-RollBackDeploymentName <String>]
    [-QueryString <String>]
    [-ValidationLevel <String>]
    [-SuppressDiagnostics]
    [-SkipTemplateParameterPrompt]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

ByTemplateSpecResourceId

Test-AzResourceGroupDeployment
    -ResourceGroupName <String>
    -TemplateSpecId <String>
    [-Mode <DeploymentMode>]
    [-RollbackToLastDeployment]
    [-RollBackDeploymentName <String>]
    [-QueryString <String>]
    [-ValidationLevel <String>]
    [-SuppressDiagnostics]
    [-SkipTemplateParameterPrompt]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

Description

The Test-AzResourceGroupDeployment cmdlet determines whether an Azure resource group deployment template and its parameter values are valid.

Examples

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

$TemplateFileText = [System.IO.File]::ReadAllText("D:\Azure\Templates\EngineeringSite.json")
$TemplateObject = ConvertFrom-Json $TemplateFileText -AsHashtable
Test-AzResourceGroupDeployment -ResourceGroupName "ContosoEngineering" -TemplateObject $TemplateObject -TemplateParameterFile "D:\Azure\Templates\EngSiteParams.json"

This command tests a deployment in the given resource group using the an in-memory hashtable created from the given template file and a parameter file.

Example 2: Test deployment via template file and parameter file

Test-AzResourceGroupDeployment -ResourceGroupName testRG01 -TemplateFile "D:\Azure\Templates\sampleDeploymentTemplate.json" -TemplateParameterFile "D:\Azure\Templates\sampleDeploymentTemplateParams.json"

This command tests a deployment in the given resource group and resource using the provided template file and a parameter file.

Example 3: Use a .bicepparam file to validate a deployment

Test-AzResourceGroupDeployment -ResourceGroupName "myRG1" -TemplateParameterFile "./parameters.bicepparam"

This command validates the deployment at the resource group scope by using a .bicepparam file on disk. The command uses the TemplateParameterFile parameter to specify a .bicepparam file.

Parameters

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with azure

Parameter properties

Type:IAzureContextContainer
Default value:None
Supports wildcards:False
DontShow:False
Aliases:AzContext, AzureRmContext, AzureCredential

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Mode

Specifies the deployment mode. The acceptable values for this parameter are:

  • Incremental
  • Complete

Parameter properties

Type:DeploymentMode
Default value:None
Accepted values:Incremental, Complete
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-Pre

Indicates that this cmdlet considers pre-release API versions when it automatically determines which version to use.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-QueryString

The query string (for example, a SAS token) to be used with the TemplateUri parameter. Would be used in case of linked templates

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ResourceGroupName

Specifies the name of the resource group to test.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-RollBackDeploymentName

Rollback to the successful deployment with the given name in the resource group, should not be used if -RollbackToLastDeployment is used.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-RollbackToLastDeployment

Rollback to the last successful deployment in the resource group, should not be present if -RollBackDeploymentName is used.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments: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.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-SuppressDiagnostics

When set, validation diagnostics will not be shown for valid deployments.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-TemplateFile

Specifies the full path of a template file. Supported template file type: json and bicep.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ByTemplateFileWithNoParameters
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ByTemplateFileAndParameterObject
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ByTemplateFileAndParameterFile
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ByTemplateFileAndParameterUri
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-TemplateObject

A hash table which represents the template.

Parameter properties

Type:Hashtable
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ByTemplateObjectAndParameterObject
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ByTemplateObjectAndParameterFile
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ByTemplateObjectAndParameterUri
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ByTemplateObjectWithNoParameters
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-TemplateParameterFile

Specifies the full path of a JSON file that contains the names and values of the template parameters.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ByTemplateObjectAndParameterFile
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ByTemplateFileAndParameterFile
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ByTemplateUriAndParameterFile
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ByTemplateSpecResourceIdAndParams
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ByParameterFileWithNoTemplate
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-TemplateParameterObject

Specifies a hash table of template parameter names and values.

Parameter properties

Type:Hashtable
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ByTemplateObjectAndParameterObject
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ByTemplateFileAndParameterObject
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ByTemplateUriAndParameterObject
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ByTemplateSpecResourceIdAndParamsObject
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-TemplateParameterUri

Specifies the URI of a template parameters file.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ByTemplateObjectAndParameterUri
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ByTemplateFileAndParameterUri
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ByTemplateUriAndParameterUri
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ByTemplateSpecResourceIdAndParamsUri
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-TemplateSpecId

Resource ID of the templateSpec to be deployed.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ByTemplateSpecResourceIdAndParamsObject
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ByTemplateSpecResourceIdAndParams
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ByTemplateSpecResourceIdAndParamsUri
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ByTemplateSpecResourceId
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-TemplateUri

Specifies the URI of a template file.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ByTemplateUriAndParameterObject
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ByTemplateUriAndParameterFile
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ByTemplateUriAndParameterUri
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ByTemplateUriWithNoParameters
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-ValidationLevel

Sets the validation level for validate/what-if. ValidationLevel can be Template(Skips provider validation), Provider(Performs full validation), or ProviderNoRbac(Performs full validation using RBAC read checks instead of RBAC write checks for provider validation).

Parameter properties

Type:String
Default value:None(Provider)
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

String

DeploymentMode

Hashtable

Outputs

PSResourceManagerError