gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 02:11:14 32 4
gpt4 key购买 nike

我正在尝试使用 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 "$biceptemplate\main.parameters.json" `
-TemplateFile "$biceptemplate\main.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: {}
}

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

关于Azure Bicep 为 Azure 应用服务计划部署提供 InvalidTemplateDeployment 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73328950/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com