你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Test-AzManagementGroupDeployment

验证管理组中的部署。

语法

ByTemplateFileWithNoParameters (默认值)

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>]

说明

Test-AzManagementGroupDeployment cmdlet 确定部署模板及其参数值在管理组中是否有效。

示例

示例 1:使用自定义模板和参数文件测试部署

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

此命令使用给定的模板文件和参数文件测试管理组“myMG”的部署。

示例 2:使用自定义模板对象和参数文件测试部署

$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"

此命令使用从给定模板文件和参数文件创建的内存中哈希表测试管理组“myMG”上的部署。

示例 3:使用 .bicepparam 文件验证部署

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

此命令使用磁盘上的 .bicepparam 文件验证管理组范围内的部署。 该命令使用 TemplateParameterFile 参数指定 .bicepparam 文件。

参数

-DefaultProfile

用于与 Azure 通信的凭据、帐户、租户和订阅。

参数属性

类型:IAzureContextContainer
默认值:None
支持通配符:False
不显示:False
别名:AzContext, AzureRmContext, AzureCredential

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Location

用于存储部署数据的位置。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-ManagementGroupId

管理组 ID。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Name

要测试的部署的名称。 如果未指定,则提供模板文件时默认为模板文件名

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False
别名:部署名称

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Pre

设置时,指示 cmdlet 应在自动确定要使用的版本时使用预发布 API 版本。

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-QueryString

要与 TemplateUri 参数一起使用的查询字符串(例如 SAS 令牌)。 在链接模板的情况下使用

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-SkipTemplateParameterPrompt

跳过 PowerShell 动态参数处理,用于检查提供的模板参数是否包含模板使用的所有必要参数。 此检查将提示用户提供缺失参数的值,但提供 -SkipTemplateParameterPrompt 会立即忽略此提示,如果发现参数未在模板中绑定,则会立即出错。 对于非交互式脚本,可以提供 -SkipTemplateParameterPrompt,以便在未满足所有必需参数的情况下提供更好的错误消息。

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-SuppressDiagnostics

设置后,不会为有效部署显示验证诊断。

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-TemplateFile

模板文件的本地路径。 支持的模板文件类型:json 和 bicep。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

ByTemplateFileWithNoParameters
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False
ByTemplateFileAndParameterObject
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False
ByTemplateFileAndParameterFile
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False
ByTemplateFileAndParameterUri
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-TemplateObject

表示模板的哈希表。

参数属性

类型:Hashtable
默认值:None
支持通配符:False
不显示:False

参数集

ByTemplateObjectAndParameterObject
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False
ByTemplateObjectAndParameterFile
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False
ByTemplateObjectAndParameterUri
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False
ByTemplateObjectWithNoParameters
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-TemplateParameterFile

要用于模板的参数文件。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

ByTemplateObjectAndParameterFile
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False
ByTemplateFileAndParameterFile
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False
ByTemplateUriAndParameterFile
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False
ByTemplateSpecResourceIdAndParams
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False
ByParameterFileWithNoTemplate
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-TemplateParameterObject

表示参数的哈希表。

参数属性

类型:Hashtable
默认值:None
支持通配符:False
不显示:False

参数集

ByTemplateObjectAndParameterObject
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False
ByTemplateFileAndParameterObject
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False
ByTemplateUriAndParameterObject
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False
ByTemplateSpecResourceIdAndParamsObject
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-TemplateParameterUri

模板参数文件的 URI。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

ByTemplateObjectAndParameterUri
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False
ByTemplateFileAndParameterUri
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False
ByTemplateUriAndParameterUri
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False
ByTemplateSpecResourceIdAndParamsUri
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-TemplateSpecId

要部署的 templateSpec 的资源 ID。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

ByTemplateSpecResourceIdAndParamsObject
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False
ByTemplateSpecResourceIdAndParams
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False
ByTemplateSpecResourceIdAndParamsUri
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False
ByTemplateSpecResourceId
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-TemplateUri

模板文件的 URI。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

ByTemplateUriAndParameterObject
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False
ByTemplateUriAndParameterFile
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False
ByTemplateUriAndParameterUri
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False
ByTemplateUriWithNoParameters
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-ValidationLevel

设置 validate/what-if 的验证级别。 ValidationLevel 可以是 Template(跳过提供程序验证)、Provider(执行完全验证)或 ProviderNoRbac(使用 RBAC 读取检查而不是 RBAC 写入检查进行提供程序验证)执行完全验证。

参数属性

类型:String
默认值:None(Provider)
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

CommonParameters

此 cmdlet 支持通用参数:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 有关详细信息,请参阅 about_CommonParameters

输入

Hashtable

String

输出

PSResourceManagerError