Azure - 简单的JSON模板和参数文件,但仍然提示输入

问题描述 投票:0回答:1

在Azure门户中,我已经通过向导来设置新的vNet虚拟网络。在创建之前,我已经从Azure门户下载了包含JSON的zip文件包,并取消了创建

使用从Azure保持不变的2个JSON(附加),我使用简单的2行Powershell脚本...

$resourceGroupName = "RG-SBX-MYTEST"
New-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroupName -Name deploy_vNet -TemplateFile "C:\Azure\vNet\template.json" -TemplateParameterFile "C:\Azure\vNet\parameters.json"

当它运行时,它会提示我输入nameFromTemplate和resourceGroupFromTemplate,但是来自parameters.json文件的所有其他值都被尊重了...... ???

cmdlet New-AzureRmResourceGroupDeployment at command pipeline position 1
Supply values for the following parameters:
(Type !? for Help.)
nameFromTemplate: vNet-SBX-MYTEST
resourceGroupFromTemplate: RG-SBX-MYTEST


DeploymentName          : deploy_vNet
ResourceGroupName       : RG-SBX-MYTEST
ProvisioningState       : Succeeded
Timestamp               : 19/02/2019 12:00:28
Mode                    : Incremental
TemplateLink            : 
Parameters              : 
                          Name             Type                       Value     
                          ===============  =========================  ==========
                          name             String                     vNet-SBX-MYTEST
                          resourceGroup    String                     RG-SBX-MYTEST
                          location         String                     westeurope
                          addressPrefix    String                     10.1.0.0/16
                          subnetName       String                     default   
                          subnetAddressPrefix  String                     10.1.0.0/24
                          enableDdosProtection  Bool                       False     

Outputs                 : 
DeploymentDebugLogLevel :

我不明白这里的问题是什么?请帮忙,这应该是简单的吗?我不期望两个提示参数文件已有的值

提前致谢!

parameters.json文件

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "name": {
            "value": "vNet-SBX-MYTEST"
        },
        "location": {
            "value": "westeurope"
        },
        "resourceGroup": {
            "value": "RG-SBX-MYTEST"
        },
        "addressPrefix": {
            "value": "10.1.0.0/16"
        },
        "subnetName": {
            "value": "default"
        },
        "subnetAddressPrefix": {
            "value": "10.1.0.0/24"
        },
        "enableDdosProtection": {
            "value": false
        }
    }
}

template.json文件

{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "name": {
            "type": "string"
        },
        "resourceGroup": {
            "type": "string"
        },
        "location": {
            "type": "string"
        },
        "addressPrefix": {
            "type": "string"
        },
        "subnetName": {
            "type": "string"
        },
        "subnetAddressPrefix": {
            "type": "string"
        },
        "enableDdosProtection": {
            "type": "bool"
        }
    },
    "resources": [
        {
            "apiVersion": "2018-08-01",
            "name": "[parameters('name')]",
            "type": "Microsoft.Network/virtualNetworks",
            "location": "[parameters('location')]",
            "properties": {
                "addressSpace": {
                    "addressPrefixes": [
                        "[parameters('addressPrefix')]"
                    ]
                },
                "subnets": [
                    {
                        "name": "[parameters('subnetName')]",
                        "properties": {
                            "addressPrefix": "[parameters('subnetAddressPrefix')]"
                        }
                    }
                ],
                "enableDdosProtection": "[parameters('enableDdosProtection')]"
            }
        }
    ] }
azure azure-powershell arm-template azure-template
1个回答
1
投票

我不确定究竟发生了什么,但我认为powershell因为将名为name和resourceGroup的参数传递给cmdlet和模板这一事实而感到困惑,它实际上看起来像是cmdlet中的bug \ edge案例。你可以做的一件事 - 不幸的是,别忘了给你这样的参数。

为清楚起见:解决方案是将两个参数重命名为其他参数,例如resource_name和resource_group_name(尽管第二个参数甚至不使用)

PS。你也可以在Azure Powershell github上引发一个问题:https://github.com/Azure/azure-powershell/issues

© www.soinside.com 2019 - 2024. All rights reserved.