Test-AzResourceGroupDeployment
验证资源组部署。
语法
Test-AzResourceGroupDeployment
-ResourceGroupName <String>
[-Mode <DeploymentMode>]
[-RollbackToLastDeployment]
[-RollBackDeploymentName <String>]
[-QueryString <String>]
[-ValidationLevel <String>]
[-SuppressDiagnostics]
-TemplateFile <String>
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Test-AzResourceGroupDeployment
-ResourceGroupName <String>
[-Mode <DeploymentMode>]
[-RollbackToLastDeployment]
[-RollBackDeploymentName <String>]
[-QueryString <String>]
[-ValidationLevel <String>]
[-SuppressDiagnostics]
-TemplateParameterObject <Hashtable>
-TemplateObject <Hashtable>
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Test-AzResourceGroupDeployment
-ResourceGroupName <String>
[-Mode <DeploymentMode>]
[-RollbackToLastDeployment]
[-RollBackDeploymentName <String>]
[-QueryString <String>]
[-ValidationLevel <String>]
[-SuppressDiagnostics]
-TemplateParameterObject <Hashtable>
-TemplateFile <String>
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Test-AzResourceGroupDeployment
-ResourceGroupName <String>
[-Mode <DeploymentMode>]
[-RollbackToLastDeployment]
[-RollBackDeploymentName <String>]
[-QueryString <String>]
[-ValidationLevel <String>]
[-SuppressDiagnostics]
-TemplateParameterObject <Hashtable>
-TemplateUri <String>
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Test-AzResourceGroupDeployment
-ResourceGroupName <String>
[-Mode <DeploymentMode>]
[-RollbackToLastDeployment]
[-RollBackDeploymentName <String>]
[-QueryString <String>]
[-ValidationLevel <String>]
[-SuppressDiagnostics]
-TemplateParameterObject <Hashtable>
-TemplateSpecId <String>
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Test-AzResourceGroupDeployment
-ResourceGroupName <String>
[-Mode <DeploymentMode>]
[-RollbackToLastDeployment]
[-RollBackDeploymentName <String>]
[-QueryString <String>]
[-ValidationLevel <String>]
[-SuppressDiagnostics]
-TemplateParameterFile <String>
-TemplateObject <Hashtable>
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Test-AzResourceGroupDeployment
-ResourceGroupName <String>
[-Mode <DeploymentMode>]
[-RollbackToLastDeployment]
[-RollBackDeploymentName <String>]
[-QueryString <String>]
[-ValidationLevel <String>]
[-SuppressDiagnostics]
-TemplateParameterFile <String>
-TemplateFile <String>
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Test-AzResourceGroupDeployment
-ResourceGroupName <String>
[-Mode <DeploymentMode>]
[-RollbackToLastDeployment]
[-RollBackDeploymentName <String>]
[-QueryString <String>]
[-ValidationLevel <String>]
[-SuppressDiagnostics]
-TemplateParameterFile <String>
-TemplateUri <String>
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Test-AzResourceGroupDeployment
-ResourceGroupName <String>
[-Mode <DeploymentMode>]
[-RollbackToLastDeployment]
[-RollBackDeploymentName <String>]
[-QueryString <String>]
[-ValidationLevel <String>]
[-SuppressDiagnostics]
-TemplateParameterFile <String>
-TemplateSpecId <String>
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Test-AzResourceGroupDeployment
-ResourceGroupName <String>
[-Mode <DeploymentMode>]
[-RollbackToLastDeployment]
[-RollBackDeploymentName <String>]
[-QueryString <String>]
[-ValidationLevel <String>]
[-SuppressDiagnostics]
-TemplateParameterFile <String>
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Test-AzResourceGroupDeployment
-ResourceGroupName <String>
[-Mode <DeploymentMode>]
[-RollbackToLastDeployment]
[-RollBackDeploymentName <String>]
[-QueryString <String>]
[-ValidationLevel <String>]
[-SuppressDiagnostics]
-TemplateParameterUri <String>
-TemplateObject <Hashtable>
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Test-AzResourceGroupDeployment
-ResourceGroupName <String>
[-Mode <DeploymentMode>]
[-RollbackToLastDeployment]
[-RollBackDeploymentName <String>]
[-QueryString <String>]
[-ValidationLevel <String>]
[-SuppressDiagnostics]
-TemplateParameterUri <String>
-TemplateFile <String>
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Test-AzResourceGroupDeployment
-ResourceGroupName <String>
[-Mode <DeploymentMode>]
[-RollbackToLastDeployment]
[-RollBackDeploymentName <String>]
[-QueryString <String>]
[-ValidationLevel <String>]
[-SuppressDiagnostics]
-TemplateParameterUri <String>
-TemplateUri <String>
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Test-AzResourceGroupDeployment
-ResourceGroupName <String>
[-Mode <DeploymentMode>]
[-RollbackToLastDeployment]
[-RollBackDeploymentName <String>]
[-QueryString <String>]
[-ValidationLevel <String>]
[-SuppressDiagnostics]
-TemplateParameterUri <String>
-TemplateSpecId <String>
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Test-AzResourceGroupDeployment
-ResourceGroupName <String>
[-Mode <DeploymentMode>]
[-RollbackToLastDeployment]
[-RollBackDeploymentName <String>]
[-QueryString <String>]
[-ValidationLevel <String>]
[-SuppressDiagnostics]
-TemplateObject <Hashtable>
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Test-AzResourceGroupDeployment
-ResourceGroupName <String>
[-Mode <DeploymentMode>]
[-RollbackToLastDeployment]
[-RollBackDeploymentName <String>]
[-QueryString <String>]
[-ValidationLevel <String>]
[-SuppressDiagnostics]
-TemplateUri <String>
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Test-AzResourceGroupDeployment
-ResourceGroupName <String>
[-Mode <DeploymentMode>]
[-RollbackToLastDeployment]
[-RollBackDeploymentName <String>]
[-QueryString <String>]
[-ValidationLevel <String>]
[-SuppressDiagnostics]
-TemplateSpecId <String>
[-SkipTemplateParameterPrompt]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
说明
Test-AzResourceGroupDeployment cmdlet 确定 Azure 资源组部署模板及其参数值是否有效。
示例
示例 1:使用自定义模板对象和参数文件测试部署
$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"
此命令使用从给定模板文件和参数文件创建的内存中哈希表测试给定资源组中的部署。
示例 2:通过模板文件和参数文件测试部署
Test-AzResourceGroupDeployment -ResourceGroupName testRG01 -TemplateFile "D:\Azure\Templates\sampleDeploymentTemplate.json" -TemplateParameterFile "D:\Azure\Templates\sampleDeploymentTemplateParams.json"
此命令使用提供的模板文件和参数文件测试给定资源组和资源中的部署。
示例 3:使用 .bicepparam 文件验证部署
Test-AzResourceGroupDeployment -ResourceGroupName "myRG1" -TemplateParameterFile "./parameters.bicepparam"
此命令使用磁盘上的 .bicepparam 文件验证资源组范围内的部署。 该命令使用 TemplateParameterFile 参数指定 .bicepparam 文件。
参数
-DefaultProfile
用于与 azure 通信的凭据、帐户、租户和订阅
类型: | IAzureContextContainer |
别名: | AzContext, AzureRmContext, AzureCredential |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Mode
指定部署模式。 此参数的可接受值为:
- 增量
- 完成
类型: | DeploymentMode |
接受的值: | Incremental, Complete |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | True |
接受通配符: | False |
-Pre
指示此 cmdlet 在自动确定要使用的版本时会考虑预发布 API 版本。
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-QueryString
要与 TemplateUri 参数一起使用的查询字符串(例如 SAS 令牌)。 在链接模板的情况下使用
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-ResourceGroupName
指定要测试的资源组的名称。
类型: | String |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | False |
-RollBackDeploymentName
如果使用 -RollbackToLastDeployment,则不应使用资源组中具有给定名称的成功部署。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | True |
接受通配符: | False |
-RollbackToLastDeployment
如果使用 -RollBackDeploymentName,则不应在资源组中回滚到最后一个成功的部署。
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-SkipTemplateParameterPrompt
跳过 PowerShell 动态参数处理,用于检查提供的模板参数是否包含模板使用的所有必要参数。 如果发现参数未在模板中绑定,则此检查会提示用户提供缺失参数的值,但提供 -SkipTemplateParameterPrompt 将立即忽略此提示并立即出错。 对于非交互式脚本,可以提供 -SkipTemplateParameterPrompt,以便在未满足所有必需参数的情况下提供更好的错误消息。
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-SuppressDiagnostics
设置后,不会为有效部署显示验证诊断。
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-TemplateFile
指定模板文件的完整路径。 支持的模板文件类型:json 和 bicep。
类型: | String |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | False |
-TemplateObject
表示模板的哈希表。
类型: | Hashtable |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | False |
-TemplateParameterFile
指定包含模板参数名称和值的 JSON 文件的完整路径。
类型: | String |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | False |
-TemplateParameterObject
指定模板参数名称和值的哈希表。
类型: | Hashtable |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | False |
-TemplateParameterUri
指定模板参数文件的 URI。
类型: | String |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | False |
-TemplateSpecId
要部署的 templateSpec 的资源 ID。
类型: | String |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | False |
-TemplateUri
指定模板文件的 URI。
类型: | String |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | False |
-ValidationLevel
设置 validate/what-if 的验证级别。 ValidationLevel 可以是 Template(跳过提供程序验证)、Provider(执行完全验证)或 ProviderNoRbac(使用 RBAC 读取检查而不是 RBAC 写入检查进行提供程序验证)执行完全验证。
类型: | String |
Position: | Named |
默认值: | None(Provider) |
必需: | False |
接受管道输入: | False |
接受通配符: | False |