Search code examples
.netazure.net-coreazure-appserviceazure-app-service-plans

Cannot run .NET Core application on Linux in Azure App Services with linuxFxVersion: 'DOTNETCORE:8.0'


When I define my .NET Core application to run on Linux in Azure App Services with linuxFxVersion: 'DOTNETCORE:8.0' and reserved: true, I keep getting HTTP 404 responses from Nginx.

The application works fine on Windows in Azure App Services.

Looking at the logs, it seems like App Services is downloading a PHP image, which outputs a version of PHP 8.0.x.

Has anyone experienced something similar and knows how to fix it?

enter image description here

Code:

resource appServicePlan 'Microsoft.Web/serverfarms@2022-03-01' = {
  name: appServicePlanName
  location: location
  sku: environmentConfigurationMap[environment].appServicePlan.sku
  properties: {
    reserved: true
  }
  kind: 'linux'
}

resource appServiceApp 'Microsoft.Web/sites@2022-03-01' = {
  name: appServiceAppName
  location: location
  identity: { type: 'SystemAssigned' }
  properties: {
    serverFarmId: appServicePlan.id
    httpsOnly: true
    siteConfig: {
      linuxFxVersion: 'DOTNETCORE:8.0'
      // netFrameworkVersion: 'v8.0'
      appSettings: [
        {
          name: 'APPINSIGHTS_INSTRUMENTATIONKEY'
          value: applicationInsights.properties.InstrumentationKey
        }
        {
          name: 'APPLICATIONINSIGHTS_CONNECTION_STRING'
          value: applicationInsights.properties.ConnectionString
        }
      ]
    }
  }
}

Error:

enter image description here

enter image description here


Solution

  • The right syntax for setting a .NET version in linuxFxVersion is DOTNETCORE|x.x, even for .NET 6 or .NET 8.

    So instead of:

    DOTNETCORE:8.0
    

    Use:

    DOTNETCORE|8.0
    

    Available built-in stacks for Web Apps and Function Apps

    You can run the az webapp list-runtimes to list the available built-in stacks which can be used for web apps, but as mentioned in the comments of the question this list doesn't seem to be correct (: is not the right separator):

    C:\Users\ruija> az webapp list-runtimes --os-type linux --output table
    
    Result
    --------------------------
    DOTNETCORE:9.0
    DOTNETCORE:8.0
    DOTNETCORE:7.0
    DOTNETCORE:6.0
    NODE:20-lts
    NODE:18-lts
    NODE:16-lts
    PYTHON:3.12
    PYTHON:3.11
    PYTHON:3.10
    PYTHON:3.9
    PYTHON:3.8
    PHP:8.3
    PHP:8.2
    PHP:8.1
    PHP:8.0
    JAVA:21-java21
    JAVA:17-java17
    JAVA:11-java11
    JAVA:8-jre8
    JBOSSEAP:8-java17
    JBOSSEAP:8-java11
    JBOSSEAP:8.0.2-java17_byol
    JBOSSEAP:8.0.2-java11_byol
    JBOSSEAP:7-java17
    JBOSSEAP:7-java11
    JBOSSEAP:7-java8
    TOMCAT:10.1-java21
    TOMCAT:10.1-java17
    TOMCAT:10.1-java11
    TOMCAT:10.0-java17
    TOMCAT:10.0-java11
    TOMCAT:10.0-jre8
    TOMCAT:9.0-java21
    TOMCAT:9.0-java17
    TOMCAT:9.0-java11
    TOMCAT:9.0-jre8
    TOMCAT:8.5-java11
    TOMCAT:8.5-jre8
    

    Running the equivalent command for Function Apps (az functionapp list-runtimes) returns a different list:

    PS C:\Users\myself> az functionapp list-runtimes --os linux --query "[].linux_fx_version" --output table
    
    Result
    -------------------
    DOTNET-ISOLATED|9.0
    DOTNET-ISOLATED|8.0
    DOTNET-ISOLATED|7.0
    DOTNET-ISOLATED|6.0
    DOTNET|8.0
    DOTNET|6.0
    Node|22
    Node|20
    Node|18
    Python|3.11
    Python|3.10
    Python|3.9
    Python|3.8
    Python|3.7
    Java|21
    Java|17
    Java|11
    Java|8
    PowerShell|7.4
    PowerShell|7.2