Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure-简单的JSON模板和参数文件,但仍然提示输入_Azure_Azure Powershell_Arm Template_Azure Template - Fatal编程技术网

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

Azure-简单的JSON模板和参数文件,但仍然提示输入,azure,azure-powershell,arm-template,azure-template,Azure,Azure Powershell,Arm Template,Azure Template,在Azure门户中,我通过向导设置了一个新的vNet虚拟网络。在创建之前,我已经从Azure门户下载了包含JSON的zip文件包,并取消了创建 使用从Azure附加的2段保持不变的JSON,我使用了一个简单的2行Powershell脚本 $resourceGroupName = "RG-SBX-MYTEST" New-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroupName -Name deploy_vNet -Te

在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
        }
    }
}
{
    "$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')]"
            }
        }
    ] }
template.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
        }
    }
}
{
    "$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')]"
            }
        }
    ] }

我不确定到底发生了什么,但我认为powershell被您向cmdlet和模板传递名为name和resourceGroup的参数这一事实弄糊涂了,它看起来确实像cmdlet中的bug\edge案例。有一件事你可以做——不幸的是,不要那样调用你的参数

为清晰起见:解决方案是将这两个参数重命名为其他名称,如resource\u name和resource\u group\u name,但第二个参数甚至没有使用


另外,你也可以在Azure Powershell github上提出一个问题:

你甚至在模板中没有这些参数,所以你显然做错了什么,可能部署了错误的模板。你看到的就是我所有的,直接从Azure portalah等一下,我记得,我已经有一段时间没看到了,我认为它的Powershell行为怪异,您可以将名称和资源组重命名为其他名称吗?是否在模板和参数文件中都添加前缀?您只需删除resourcegroup参数,它甚至used@4c74356b41是的,这很有效。那么Powershell怎么了?这是我第一次在Azure中将基础设施作为代码使用,到目前为止我已经浪费了一天!如果我能做些什么来修复Powershell,那就太棒了。如果你被卡住了,你可以随时来这里问问题。谢谢,如果是这样的话,那就很有趣了。我只用了10分钟就发现了一个bug!干杯更新:自2016年以来,这一直是一个bug,微软似乎不愿意修复。令人惊讶的简单,但不会被打扰