简体   繁体   中英

Azure Bicep giving InvalidTemplateDeployment error for Azure App Service Plan deployment

I'm trying to create App Service Plan using Bicep. I've created a full blown bicep script for the development infra and it is working fine. But for production when I'm executing the app Service plan module, I'm receiving the below error. I've almost spent a day for troubleshooting this issue. The module was also having bicep for deploying and configuring App Services. But for troubleshooting I've removed it. Kindly help me in identifying this issue.

Main file

@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
  }
}

Module

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'
}

Execucted using 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 ....

Try this for your module:

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: {}
}

Supplying an empty properties object on the resource. It shouldn't be required but seems like it is in this case and bicep didn't flag it. (issue here )

Thanks...adding Properties fixed my issues... Looks like a bug...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM