Azure - 简单 JSON 模板和参数文件,但仍提示输入
Azure - Simple JSON template and parameter file and yet still prompts for input
在 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')]"
}
}
] }
我不确定到底发生了什么,但我认为 powershell 对您将名为 name 和 resourceGroup 的参数传递给 cmdlet 和模板这一事实感到困惑,它看起来确实像 bug\edge cmdlet 中的大小写。你可以做的一件事 - 不幸的是,避免那样调用你的参数。
为清楚起见:解决方案是将两个参数重命名为其他名称,例如 resource_name 和 resource_group_name(尽管甚至没有使用第二个参数)
ps。您还可以在 Azure Powershell github 上提出问题:https://github.com/Azure/azure-powershell/issues
在 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')]"
}
}
] }
我不确定到底发生了什么,但我认为 powershell 对您将名为 name 和 resourceGroup 的参数传递给 cmdlet 和模板这一事实感到困惑,它看起来确实像 bug\edge cmdlet 中的大小写。你可以做的一件事 - 不幸的是,避免那样调用你的参数。
为清楚起见:解决方案是将两个参数重命名为其他名称,例如 resource_name 和 resource_group_name(尽管甚至没有使用第二个参数)
ps。您还可以在 Azure Powershell github 上提出问题:https://github.com/Azure/azure-powershell/issues