dfr
dfr

Reputation: 11

Error when deploying .NET 8 stack Linux App Service with Bicep

I am trying to make a simple Bicep module that will be able to deploy a .NET App Service on Linux and I am getting an Internal Server Error when trying to create the resource.

After creating the dotnet_app_service.bicep that looks like this:

targetScope = 'resourceGroup'

param location string = resourceGroup().location
param project string
param app_service_name string
param environment string
param instance int
param app_service_plan_id string
param dotnet_version string
param app_settings array

var name = toLower('app-${app_service_name}-${environment}-00${instance}')
resource app_service 'Microsoft.Web/sites@2024-04-01' = {
  name: name
  location: location
  kind: 'app,linux'
  identity: {
    type: 'SystemAssigned'
  }
  properties: {
    serverFarmId: app_service_plan_id
    siteConfig: {
      netFrameworkVersion: 'v${dotnet_version}'
      appSettings: app_settings
    }
  }
  tags: {
    DevOpsProject: project
    IaC: 'true'
  }
}

I tried deploying the resource with the Azure CLI command:

az deployment group create --resource-group <my_resource_group> --subscription <my_subscription_id> --parameters environment=test instance=1 linux_app_service_plan_name=<my_project_name> linux_app_service_plan_sku=F1 --template-file main.bicep

Where the main.bicep provides the rest of parameters:

But I am getting the following error on a JSON output on the console:

There was an unexpected InternalServerError.  Please try again later.

I do not manage to get any answer further from here as Internal Server Error is usually something related to the other end? Hope to get some help related to this topic. Thanks!

Upvotes: 1

Views: 61

Answers (1)

Thomas
Thomas

Reputation: 29736

For linux app service, you need to specify the linuxFxVersion property:

linuxFxVersion: 'DOTNETCORE|${dotnet_version}'

Full sample:

param location string = resourceGroup().location
param app_service_plan_name  string = 'thomas-test-123-asp'
param app_service_name  string = 'thomas-test-123-web'
param dotnet_version string = '8.0'

resource app_service_plan 'Microsoft.Web/serverfarms@2024-04-01' = {
  name: app_service_plan_name
  location: location
  kind: 'linux'
  sku: {
    name: 'B1'
    tier: 'Basic'
  }
  properties: {
    reserved: true
  }
}

resource app_service 'Microsoft.Web/sites@2024-04-01' = {
  name: app_service_name
  location: location
  kind: 'app,linux'
  identity: {
    type: 'SystemAssigned'
  }
  properties: {
    serverFarmId: app_service_plan.id
    siteConfig: {
      linuxFxVersion: 'DOTNETCORE|${dotnet_version}'
      appSettings: []
    }
  }
}

Upvotes: 1

Related Questions