删除了新的 Azure PowerShell 'AZ' 模块 'deployment mode'?

New Azure PowerShell 'AZ' module removed 'deployment mode'?

在 Azure Powershell 中,我正在使用 new Az module that has replaced the AzureRM module。我想将部署模式设置为 Complete,但我看不出这是如何完成的。

Caution for readers: The PowerShell 'Az' module has no relationship to the 'az' command of the Azure CLI.

我试过这个:

PS C:\repos\azure\pdi> New-AzDeployment -Name bjaDeploy -Location southcentralus -Mode Complete -TemplateParameterFile t
est.parameters.json -TemplateFile testrg.json
New-AzDeployment : A parameter cannot be found that matches parameter name 'Mode'.
At line:1 char:59
+ ... w-AzDeployment -Name bjaDeploy -Location southcentralus -Mode Complet ...
+                                                             ~~~~~
    + CategoryInfo          : InvalidArgument: (:) [New-AzDeployment], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.N
ewAzureDeploymentCmdlet

不足为奇,Get-Help New-AzDeployment 显示了命令行开关,其中 none 包括 Mode

我也尝试过将部署模式直接放入 ARM 模板中:

"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.1",
"parameters": {
    "rgName": {
        "type": "string"
    },
    "rgLocation": {
        "type": "string"
    }
},
"variables": {},
"resources": [
    {
        "type": "Microsoft.Resources/resourceGroups",
        "apiVersion": "2018-05-01",
        "location": "[parameters('rgLocation')]",
        "name": "[parameters('rgName')]",
        "properties": {
            "mode": "Complete"
        }
    }
],
"outputs": {}

Visual Studio 代码中的智能提示告诉我 "mode" 属性 是非法的,果然,当我尝试部署它时它会出错。所以不清楚如何从命令提示符执行此操作,也不清楚为什么它不是 ARM 模板本身的一个选项。

有什么想法吗?我需要一个特定于 'Az' 模块的答案。我不打算使用现已弃用的 AzureRM。

我想你正在寻找 New-AzResourceGroupDeployment,它有 -Mode 参数。

New-AzDeployment 迁移自 New-AzureRmDeployment which also not have the -Mode parameter, if you used to use AzureRM powershell to do that, I suppose it maybe New-AzureRmResourceGroupDeployment