Edit

Share via


Test-AzManagementGroupDeployment

Validates a deployment at a management group.

Syntax

ByTemplateFileWithNoParameters (Default)

Test-AzManagementGroupDeployment
    -ManagementGroupId <String>
    -Location <String>
    -TemplateFile <String>
    [-Name <String>]
    [-QueryString <String>]
    [-ValidationLevel <String>]
    [-SuppressDiagnostics]
    [-SkipTemplateParameterPrompt]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

ByTemplateObjectAndParameterObject

Test-AzManagementGroupDeployment
    -ManagementGroupId <String>
    -Location <String>
    -TemplateParameterObject <Hashtable>
    -TemplateObject <Hashtable>
    [-Name <String>]
    [-QueryString <String>]
    [-ValidationLevel <String>]
    [-SuppressDiagnostics]
    [-SkipTemplateParameterPrompt]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

ByTemplateFileAndParameterObject

Test-AzManagementGroupDeployment
    -ManagementGroupId <String>
    -Location <String>
    -TemplateParameterObject <Hashtable>
    -TemplateFile <String>
    [-Name <String>]
    [-QueryString <String>]
    [-ValidationLevel <String>]
    [-SuppressDiagnostics]
    [-SkipTemplateParameterPrompt]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

ByTemplateUriAndParameterObject

Test-AzManagementGroupDeployment
    -ManagementGroupId <String>
    -Location <String>
    -TemplateParameterObject <Hashtable>
    -TemplateUri <String>
    [-Name <String>]
    [-QueryString <String>]
    [-ValidationLevel <String>]
    [-SuppressDiagnostics]
    [-SkipTemplateParameterPrompt]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

ByTemplateSpecResourceIdAndParamsObject

Test-AzManagementGroupDeployment
    -ManagementGroupId <String>
    -Location <String>
    -TemplateParameterObject <Hashtable>
    -TemplateSpecId <String>
    [-Name <String>]
    [-QueryString <String>]
    [-ValidationLevel <String>]
    [-SuppressDiagnostics]
    [-SkipTemplateParameterPrompt]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

ByTemplateObjectAndParameterFile

Test-AzManagementGroupDeployment
    -ManagementGroupId <String>
    -Location <String>
    -TemplateParameterFile <String>
    -TemplateObject <Hashtable>
    [-Name <String>]
    [-QueryString <String>]
    [-ValidationLevel <String>]
    [-SuppressDiagnostics]
    [-SkipTemplateParameterPrompt]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

ByTemplateFileAndParameterFile

Test-AzManagementGroupDeployment
    -ManagementGroupId <String>
    -Location <String>
    -TemplateParameterFile <String>
    -TemplateFile <String>
    [-Name <String>]
    [-QueryString <String>]
    [-ValidationLevel <String>]
    [-SuppressDiagnostics]
    [-SkipTemplateParameterPrompt]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

ByTemplateUriAndParameterFile

Test-AzManagementGroupDeployment
    -ManagementGroupId <String>
    -Location <String>
    -TemplateParameterFile <String>
    -TemplateUri <String>
    [-Name <String>]
    [-QueryString <String>]
    [-ValidationLevel <String>]
    [-SuppressDiagnostics]
    [-SkipTemplateParameterPrompt]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

ByTemplateSpecResourceIdAndParams

Test-AzManagementGroupDeployment
    -ManagementGroupId <String>
    -Location <String>
    -TemplateParameterFile <String>
    -TemplateSpecId <String>
    [-Name <String>]
    [-QueryString <String>]
    [-ValidationLevel <String>]
    [-SuppressDiagnostics]
    [-SkipTemplateParameterPrompt]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

ByParameterFileWithNoTemplate

Test-AzManagementGroupDeployment
    -ManagementGroupId <String>
    -Location <String>
    -TemplateParameterFile <String>
    [-Name <String>]
    [-QueryString <String>]
    [-ValidationLevel <String>]
    [-SuppressDiagnostics]
    [-SkipTemplateParameterPrompt]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

ByTemplateObjectAndParameterUri

Test-AzManagementGroupDeployment
    -ManagementGroupId <String>
    -Location <String>
    -TemplateParameterUri <String>
    -TemplateObject <Hashtable>
    [-Name <String>]
    [-QueryString <String>]
    [-ValidationLevel <String>]
    [-SuppressDiagnostics]
    [-SkipTemplateParameterPrompt]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

ByTemplateFileAndParameterUri

Test-AzManagementGroupDeployment
    -ManagementGroupId <String>
    -Location <String>
    -TemplateParameterUri <String>
    -TemplateFile <String>
    [-Name <String>]
    [-QueryString <String>]
    [-ValidationLevel <String>]
    [-SuppressDiagnostics]
    [-SkipTemplateParameterPrompt]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

ByTemplateUriAndParameterUri

Test-AzManagementGroupDeployment
    -ManagementGroupId <String>
    -Location <String>
    -TemplateParameterUri <String>
    -TemplateUri <String>
    [-Name <String>]
    [-QueryString <String>]
    [-ValidationLevel <String>]
    [-SuppressDiagnostics]
    [-SkipTemplateParameterPrompt]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

ByTemplateSpecResourceIdAndParamsUri

Test-AzManagementGroupDeployment
    -ManagementGroupId <String>
    -Location <String>
    -TemplateParameterUri <String>
    -TemplateSpecId <String>
    [-Name <String>]
    [-QueryString <String>]
    [-ValidationLevel <String>]
    [-SuppressDiagnostics]
    [-SkipTemplateParameterPrompt]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

ByTemplateObjectWithNoParameters

Test-AzManagementGroupDeployment
    -ManagementGroupId <String>
    -Location <String>
    -TemplateObject <Hashtable>
    [-Name <String>]
    [-QueryString <String>]
    [-ValidationLevel <String>]
    [-SuppressDiagnostics]
    [-SkipTemplateParameterPrompt]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

ByTemplateUriWithNoParameters

Test-AzManagementGroupDeployment
    -ManagementGroupId <String>
    -Location <String>
    -TemplateUri <String>
    [-Name <String>]
    [-QueryString <String>]
    [-ValidationLevel <String>]
    [-SuppressDiagnostics]
    [-SkipTemplateParameterPrompt]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

ByTemplateSpecResourceId

Test-AzManagementGroupDeployment
    -ManagementGroupId <String>
    -Location <String>
    -TemplateSpecId <String>
    [-Name <String>]
    [-QueryString <String>]
    [-ValidationLevel <String>]
    [-SuppressDiagnostics]
    [-SkipTemplateParameterPrompt]
    [-Pre]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

Description

The Test-AzManagementGroupDeployment cmdlet determines whether a deployment template and its parameter values are valid at a management group.

Examples

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

Test-AzManagementGroupDeployment -ManagementGroupId "myMG" -Location "West US" -TemplateFile "D:\Azure\Templates\OrgSetup.json" -TemplateParameterFile "D:\Azure\Templates\OrgParms.json"

This command tests a deployment at the management group "myMG" using the given template file and parameters file.

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

$TemplateFileText = [System.IO.File]::ReadAllText("D:\Azure\Templates\OrgSetup.json")
$TemplateObject = ConvertFrom-Json $TemplateFileText -AsHashtable
Test-AzManagementGroupDeployment -ManagementGroupId "myMG" -Location "West US" -TemplateObject $TemplateObject -TemplateParameterFile "D:\Azure\Templates\EngSiteParams.json"

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

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

Test-AzManagementGroupDeployment -ManagementGroupId "myManagementGroup" -Location "West US" -TemplateParameterFile "./parameters.bicepparam"

This command validates the deployment at the management 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

-Location

The ___location to store deployment data.

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:False
Value from remaining arguments:False

-ManagementGroupId

The management group id.

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:False
Value from remaining arguments:False

-Name

The name of the deployment it's going to test. If not specified, defaults to the template file name when a template file is provided

Parameter properties

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

Parameter sets

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

-Pre

When set, indicates that the cmdlet should use pre-release API versions when automatically determining 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

-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

Local path to the 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

Parameter file to use for the template.

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

A hash table which represents the parameters.

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

Uri to the template parameter 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

Uri to the 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

Hashtable

String

Outputs

PSResourceManagerError