GitHub工作流部署Azure FunctionApp时模板验证失败求助
Azure FunctionApp ARM模板部署验证失败求助
模板文件
{"$schema":"https://schema.management.azure.com/schemas/2018-05-01/deploymentTemplate.json#","contentVersion":"1.0.0.0","parameters":{"subscriptionId":{"type":"string"},"resourceGroup":{"type":"string"},"rgTags":{"type":"object"},"funcAppName":{"type":"string"},"location":{"type":"string"},"hostingPlanName":{"type":"string"},"funcAppSku":{"type":"string"},"funcAppSkuCode":{"type":"string"},"appInsightsName":{"type":"string"},"storageAccountName":{"type":"string"},"vnetName":{"type":"string"},"laWorkspaceName":{"type":"string"},"laWorkspaceRGName":{"type":"string"},"tagEnvironment":{"type":"string"}},"resources":[{"type":"Microsoft.Resources/tags","name":"default","apiVersion":"2021-04-01","properties":{"tags":"[parameters('rgTags')]"}},{"type":"Microsoft.Web/sites","name":"[parameters('funcAppName')]","apiVersion":"2018-11-01","kind":"functionapp","location":"[parameters('location')]","tags":{"Environment":"[parameters('tagEnvironment')]"},"dependsOn":["[concat('microsoft.insights/components/', parameters('appInsightsName'))]","[concat('Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]","[concat('Microsoft.Storage/storageAccounts/', parameters('storageAccountName'))]","[concat('Microsoft.Network/virtualNetworks/', parameters('vnetName'))]"],"properties":{"name":"[parameters('funcAppName')]","siteConfig":{"appSettings":[{"name":"FUNCTIONS_EXTENSION_VERSION","value":"~4"},{"name":"FUNCTIONS_WORKER_RUNTIME","value":"powershell"},{"name":"WEBSITE_LOAD_CERTIFICATES","value":"*"},{"name":"APPINSIGHTS_INSTRUMENTATIONKEY","value":"[reference(concat('microsoft.insights/components/', parameters('appInsightsName')), '2015-05-01').InstrumentationKey]"},{"name":"APPLICATIONINSIGHTS_CONNECTION_STRING","value":"[reference(concat('microsoft.insights/components/', parameters('appInsightsName')), '2015-05-01').ConnectionString]"},{"name":"AzureWebJobsStorage","value":"[concat('DefaultEndpointsProtocol=https;AccountName=',parameters('storageAccountName'),';AccountKey=',listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), '2019-06-01').keys[0].value,';EndpointSuffix=','core.windows.net')]"},{"name":"FUNCTIONS_WORKER_PROCESS_COUNT","value":"2"},{"name":"PSWorkerInProcConcurrencyUpperBound","value":"2"}],"use32BitWorkerProcess":false,"alwaysOn":true,"powerShellVersion":"~7","http20Enabled":true,"minTlsVersion":"1.2","ftpsState":"FtpsOnly"},"serverFarmId":"[concat('/subscriptions/', parameters('subscriptionId'),'/resourcegroups/', parameters('resourceGroup'), '/providers/Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]","clientAffinityEnabled":false},"resources":[{"apiVersion":"2018-11-01","name":"virtualNetwork","type":"config","location":"[parameters('location')]","dependsOn":["[resourceId('Microsoft.Web/sites', parameters('funcAppName'))]","[concat('Microsoft.Network/virtualNetworks/', parameters('vnetName'))]"],"properties":{"subnetResourceId":"[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('vnetName'), 'default')]","swiftSupported":true}}]},{"apiVersion":"2018-11-01","name":"[parameters('hostingPlanName')]","type":"Microsoft.Web/serverfarms","location":"[parameters('location')]","kind":"","tags":{"Environment":"[parameters('tagEnvironment')]"},"dependsOn":[],"properties":{"name":"[parameters('hostingPlanName')]","workerSize":"0","workerSizeId":"0","numberOfWorkers":"1"},"sku":{"Tier":"[parameters('funcAppSku')]","Name":"[parameters('funcAppSkuCode')]"}},{"apiVersion":"2020-02-02","name":"[parameters('appInsightsName')]","type":"microsoft.insights/components","location":"[parameters('location')]","tags":{"Environment":"[parameters('tagEnvironment')]"},"dependsOn":[],"properties":{"ApplicationId":"[parameters('funcAppName')]","Request_Source":"IbizaWebAppExtensionCreate","Flow_Type":"Redfield","Application_Type":"web","WorkspaceResourceId":"[concat('/subscriptions/', parameters('subscriptionId'),'/resourceGroups/', parameters('laWorkspaceRGName'), '/providers/Microsoft.OperationalInsights/workspaces/', parameters('lAWorkspaceName'))]","IngestionMode":"LogAnalytics","publicNetworkAccessForIngestion":"Enabled","publicNetworkAccessForQuery":"Enabled"}},{"apiVersion":"2019-06-01","type":"Microsoft.Storage/storageAccounts","name":"[parameters('storageAccountName')]","location":"[parameters('location')]","tags":{"Environment":"[parameters('tagEnvironment')]"},"sku":{"name":"Standard_LRS"},"properties":{"supportsHttpsTrafficOnly":true,"minimumTlsVersion":"TLS1_2"}},{"type":"Microsoft.Network/virtualNetworks","apiVersion":"2020-11-01","name":"[parameters('vnetName')]","location":"[parameters('location')]","properties":{"addressSpace":{"addressPrefixes":["10.0.0.0/16"]},"subnets":[{"name":"default","properties":{"addressPrefix":"10.0.0.0/24","serviceEndpoints":[{"service":"Microsoft.Storage.Global","locations":["*"]}],"delegations":[{"name":"delegation","properties":{"serviceName":"Microsoft.Web/serverfarms"}}],"privateEndpointNetworkPolicies":"Enabled","privateLinkServiceNetworkPolicies":"Enabled"}}],"virtualNetworkPeerings":[],"enableDdosProtection":false},"tags":{"Environment":"[parameters('tagEnvironment')]"}}]}
参数文件
{"$schema":"https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#","contentVersion":"1.0.0.0","parameters":{"subscriptionId":{"value":""},"resourceGroup":{"value":""},"rgTags":{"value":null},"funcAppName":{"value":""},"location":{"value":""},"hostingPlanName":{"value":""},"funcAppSku":{"value":""},"funcAppSkuCode":{"value":""},"appInsightsName":{"value":""},"storageAccountName":{"value":""},"vnetName":{"value":""},"laWorkspaceName":{"value":""},"laWorkspaceRGName":{"value":""},"tagEnvironment":{"value":""}}}
错误日志
##[debug]Select-AzSubscription -Subscription dc86c13b-36f0-4b2f-a42d-1bd68ebdaaf7 ##[debug]New-AzResourceGroupDeployment -ResourceGroupName az-xxx-xxx-rg-businessfuncappxayb ##[debug]-TemplateFile arm-templates/business-subscription-afna/template.json ##[debug]-TemplateParameterFile arm-templates/business-subscription-afna/parameters.json ##[debug]script file to run: D:\a_temp\73d8fc60-7cad-4983-8b66-2d762ae62181.ps1 "C:\Program Files\PowerShell\7\pwsh.exe" -NoLogo -NoProfile -NonInteractive -Command D:\a_temp\73d8fc60-7cad-4983-8b66-2d762ae62181.ps1 New-AzResourceGroupDeployment: D:\a_temp\73d8fc60-7cad-4983-8b66-2d762ae62181.ps1:3 Line | 3 | New-AzResourceGroupDeployment -ResourceGroupName az-dna-113-rg-busine … | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 11:44:45 AM - 错误: 代码=InvalidTemplateDeployment; 消息=模板部署'template'不符合验证程序要求,跟踪ID为'xxxxxxx-f32f-459c-9487-xxxxxxxx',详情请查看内部错误。 错误: 错误: 进程'C:\Program Files\PowerShell\7\pwsh.exe'退出代码为1
排查方向
- 补全参数文件中所有空值参数,当前所有参数的
value均为空或null,这是部署失败的核心原因之一 - 检查
Microsoft.Resources/tags资源的配置:若rgTags参数为null,直接赋值会触发验证错误,需添加条件判断或确保参数有合法的键值对 - 验证应用服务计划的SKU匹配性:
funcAppSku和funcAppSkuCode需对应(例如Premium层级对应P1v2等) - 检查虚拟子网委托:确认
Microsoft.Web/serverfarms委托支持当前使用的应用服务计划SKU(消费计划不支持子网委托) - 运行验证命令获取详细错误:
Test-AzResourceGroupDeployment -ResourceGroupName az-xxx-xxx-rg-businessfuncappxayb -TemplateFile arm-templates/business-subscription-afna/template.json -TemplateParameterFile arm-templates/business-subscription-afna/parameters.json
内容的提问来源于stack exchange,提问作者Nolan1513
相关产品推荐
相关产品推荐

