【发布时间】:2020-07-03 14:39:04
【问题描述】:
我正在扩展其中一个 Azure 快速入门模板来部署带有 VNET 集成的 Azure Web 应用程序。已经创建了 RG、网络组件和应用服务计划(使用 powershell)。我正在使用 ARM 模板来部署 Web 应用程序。但我在执行部署时遇到以下错误。
我使用 JSON Lint 来验证 JSON 并且看起来没问题。错误代码告诉我参数文件的语法存在问题,但我无法查明它。我尝试了很多方法来调试它,但无法修复它。
错误:
PS C:\Users\manjug\Desktop> New-AzResourceGroupDeployment `
-Name 'test01' `
-ResourceGroupName ITQIG-eu-manjug-windows-app `
-TemplateParameterUri C:\Users\manjug\Desktop\azuredeploy_webapp.parameters.json `
-TemplateUri C:\Users\manjug\Desktop\azuredeploy_webapp.json `
-Verbose
VERBOSE: Performing the operation "Creating Deployment" on target "ITQIG-eu-manjug-windows-app".
New-AzResourceGroupDeployment : 2:22:59 PM - Error: Code=InvalidTemplate; Message=Deployment template validation failed: 'The value for the template parameter 'appName' at line '7' and
column '20' is not provided. Please see https://aka.ms/resource-manager-parameter-files for usage details.'.
At line:1 char:1
+ New-AzResourceGroupDeployment `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-AzResourceGroupDeployment], Exception
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupDeploymentCmdlet
New-AzResourceGroupDeployment : The deployment validation failed
At line:1 char:1
+ New-AzResourceGroupDeployment `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzResourceGroupDeployment], InvalidOperationException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupDeploymentCmdlet
azuredeploy_webapp.parameter.json:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appName": {
"value": "ITQIG-eu-web-manju123"
},
"kind": {
"value": "app"
},
"location": {
"value": "west europe"
},
"subnetResourceID": {
"value": "/subscriptions/7e7f55d3-4bfd-a6be-1c59594b8592/resourceGroups/ITQIG-eu-network-dev/providers/Microsoft.Network/virtualNetworks/ITQIG-eu-vnet-dev/subnets/subnet7-AWmanjug"
},
"appServicePlanResourceID": {
"value": "/subscriptions/7e7f55d3-4bfd-a6be-1c59594b8592/resourceGroups/ITQIG-eu-manjug-windows-app/providers/microsoft.web/serverFarms/eu-manjug-windows-plan"
}
}
}
azuredeploy_webapp.json
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appName": {
"type": "string",
"metadata": {
"description": "The name of the app to create."
}
},
"kind": {
"type": "string",
"metadata": {
"description": "Web app kind. OS type -> Windows / Linux."
}
},
"appServicePlanResourceID": {
"metadata": {
"description": "The resource ID of the app service plan."
},
"type": "string"
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "The location in which all resources should be deployed."
}
},
"subnetResourceID": {
"type": "string",
"metadata": {
"description": "The subnet resource ID created for app service plan which contains this web app."
}
}
},
"resources": [
{
"type": "Microsoft.Web/sites",
"apiVersion": "2019-08-01",
"name": "[parameters('appName')]",
"location": "[parameters('location')]",
"kind": "[parameters('kind')]",
"properties": {
"serverFarmId": "[parameters('appServicePlanResourceID')]"
},
"resources": [
{
"name": "virtualNetwork",
"type": "networkConfig",
"apiVersion": "2019-08-01",
"dependsOn": [
"[resourceId('Microsoft.Web/sites', parameters('appName'))]"
],
"properties": {
"subnetResourceId": "[parameters('subnetResourceId')]",
"swiftSupported": true
}
}
]
}
]
}
【问题讨论】:
标签: json azure-web-app-service azure-resource-manager azure-template