Azure Bicep为Azure应用程序服务计划部署提供InvalidTemplateDeployment错误



我正在尝试使用Bicep创建应用程序服务计划。我已经为基础设施的开发创建了一个完整的二头肌脚本,它运行良好。但对于生产,当我执行应用程序服务计划模块时,我会收到以下错误。我几乎花了一天时间来解决这个问题。该模块还具有部署和配置应用程序服务的二头肌。但为了进行故障排除,我已将其删除。请帮助我识别此问题。

主文件

@allowed([
'aladdin'
])
@description('Environment Name')
param environmentPrefix string
@allowed([
'uat'
'prod'
])
@description('Environment Type')
param environmentType string
@allowed([
'P1V3'
'P2V3'
])
@description('App Services Plan SKU')
param appServicePlanSku string
var appRgName = 'rg-${environmentPrefix}-${environmentType}-ne-app01'
var appServicePlanName = 'asp-${environmentPrefix}-${environmentType}-ne-app01'
resource appResourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = {
name: appRgName
location: location
tags: {
environmentType: environmentType
environmentPrefix: environmentPrefix
role: 'Azure PAAS resources'
}
}
module appServicePlan 'appServicePlan.bicep' = {
scope: appResourceGroup
name: 'appServicePlanModule'
params: {
appServicePlanName: appServicePlanName
appServicePlanSku: appServicePlanSku
location: location
}
}

模块

param appServicePlanSku string
param appServicePlanName string
param location string
resource appServicePlan 'Microsoft.Web/serverfarms@2022-03-01' = {
name: appServicePlanName
location: location
sku: {
name: appServicePlanSku
capacity: 1
}
kind: 'windows'
}

使用PowerShell执行

New-AzSubscriptionDeployment `
-Name Production `
-Location northeurope `
-TemplateParameterFile "$biceptemplatemain.parameters.json" `
-TemplateFile "$biceptemplatemain.bicep" `
-environmentPrefix 'aladdin' `
-verbose
Error: Code=InvalidTemplateDeployment; Message=The template deployment 'Production' is not valid according to the validation procedure. The tracking id is ....

为您的模块尝试以下操作:

param appServicePlanSku string
param appServicePlanName string
param location string
resource appServicePlan 'Microsoft.Web/serverfarms@2022-03-01' = {
name: appServicePlanName
location: location
sku: {
name: appServicePlanSku
capacity: 1
}
kind: 'windows'
properties: {}
}

在资源上提供一个空的属性对象。它不应该是必需的,但似乎是在这种情况下,二头肌没有标记它。(问题在这里(

最新更新