0

I'm trying to deploy an Azure Function App using Azure Bicep. It fails with the following error message

{
  "code": "InvalidTemplateDeployment",
  "message": "The template deployment 'functionApp' is not valid according to the validation procedure. The tracking id is '879adf4b-de3b-4041-b1ea-dbd4b456efaa'. See inner errors for details."
}

Inner Errors: {
  "message": "Object reference not set to an instance of an object."
}

I have tried to deploy each resource individually that the functions app requires (storage account, hosting plan and application insights). Storage account and application insights works fine to create. But not the hosting plan...

Can anyone see what I'm doing wrong? I have broken out the hosting part and tried to create it but get the same error message as above

The Bicep file looks like this:

param functionAppName string = 'abctest'
param env string = 'pri2'
param location string = 'westeurope'

var hostingPlanName = '${functionAppName}-${env}-plan'

resource hostingPlanName_resource 'Microsoft.Web/serverfarms@2020-10-01' = {
  name: hostingPlanName
  location: location
  sku: {
    tier: 'Y1'
    name: 'Dynamic'
  }
}

Thomas
  • 24,234
  • 6
  • 81
  • 125

1 Answers1

2

Related to this post: Azure Bicep - Object reference not set to an instance.

You need to add an empty properties object:

properties: {}

Also according to the documentation, the sku and name are invalid in your template.

Thi should work:

resource hostingPlanName_resource 'Microsoft.Web/serverfarms@2020-10-01' = {
  name: hostingPlanName
  location: location
  sku: {
    name: 'Y1'
    tier: 'Dynamic'
  }
  properties: {}
}
Thomas
  • 24,234
  • 6
  • 81
  • 125