首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Azure -简单的JSON模板和参数文件,但仍提示输入

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

Stack Overflow用户
提问于 2019-02-19 23:30:15
回答 1查看 772关注 0票数 0

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

使用Azure中保持不变的两段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"

当它运行时,它会提示我输入nameFromTemplateresourceGroupFromTemplate,,但是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')]"
            }
        }
    ] }
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-02-20 00:11:18

我不确定到底发生了什么,但我认为powershell被您将名为name和resourceGroup的参数传递给cmdlet和模板的事实搞糊涂了,这看起来真的像cmdlet中的bug\edge情况。不幸的是,你可以做的一件事就是避免调用这样的参数。

为清楚起见:解决方案是将两个参数都重命名为其他名称,如resource_name和resource_group_name (虽然,甚至没有使用第二个参数)

ps。你也可以在Azure Powershell github上提出一个问题:https://github.com/Azure/azure-powershell/issues

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54769789

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档