You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求助:Bicep模板部署Linux环境下.NET Core 3.1 Azure App Service时运行时栈配置不生效问题

Fix: Empty Runtime Stack for Linux .NET Core 3.1 App Service Deployed via Bicep

I've run into this exact issue before, and the problem stems from two key gaps in your current configuration: incorrect kind property for the App Service, and Bicep's type validation blocking the metadata property. Here's how to fix it properly:

Key Fixes to Apply

1. Set the Correct kind for Your Linux App Service

Your App Service's kind property is currently set to just app, but you need to explicitly mark it as a Linux app. Change it to:

kind: 'linux,app'

This tells Azure's portal and runtime that this is a Linux-based service, which is critical for the runtime stack to be recognized.

2. Bypass Bicep Type Validation for metadata (or Use a Newer API Version)

Bicep's built-in type definitions for SiteConfig don't include the metadata property yet, but you can either:

Option A: Use Extension Property Syntax (Works with Any API Version)

Use Bicep's @('propertyName') syntax to add the unsupported metadata property without triggering validation errors:

siteConfig: {
  linuxFxVersion: 'dotnet|3.1'
  appCommandLine: 'dotnet MyApp.dll'
  // Bypass type check to add metadata
  @('metadata'): [
    {
      name: 'CURRENT_STACK'
      value: 'dotnetcore'
    }
  ]
}

Option B: Upgrade to a Newer API Version

Newer API versions (like 2022-03-01 or later) have updated type definitions that include metadata in SiteConfig. Just update your App Service resource's API version:

resource appService 'Microsoft.Web/sites@2022-03-01' = {
  // ... rest of your config
  siteConfig: {
    linuxFxVersion: 'dotnet|3.1'
    appCommandLine: 'dotnet MyApp.dll'
    // No need for extension syntax here
    metadata: [
      {
        name: 'CURRENT_STACK'
        value: 'dotnetcore'
      }
    ]
  }
}

Full Working Bicep Example

Here's the complete, corrected template using Option A (compatible with your original API version):

resource appServicePlan 'Microsoft.Web/serverfarms@2021-02-01' = {
  name: 'MyAppService'
  location: resourceGroup().location
  properties: {
    reserved: true
  }
  sku: {
    name: 'P1v2'
  }
  kind: 'linux'
}

resource appService 'Microsoft.Web/sites@2021-02-01' = {
  name: 'MyApp'
  location: resourceGroup().location
  identity: {
    type: 'SystemAssigned'
  }
  // Mark as Linux app
  kind: 'linux,app'
  properties: {
    enabled: true
    serverFarmId: appServicePlan.id
    siteConfig: {
      linuxFxVersion: 'dotnet|3.1'
      appCommandLine: 'dotnet MyApp.dll'
      // Add metadata via extension property
      @('metadata'): [
        {
          name: 'CURRENT_STACK'
          value: 'dotnetcore'
        }
      ]
    }
  }
}

Why This Works

  • The linux,app kind ensures Azure recognizes the service as a Linux app, so the portal will display the runtime stack correctly once configured.
  • The extension property syntax lets you pass the CURRENT_STACK metadata to ARM despite Bicep's type checks, which fixes the empty runtime stack issue.
  • Using a newer API version eliminates the need for the extension syntax by updating Bicep's type definitions to include the metadata property.

After deploying this template, your App Service's runtime stack should be automatically set to .NET Core 3.1 in the Azure portal, no manual configuration required.

内容的提问来源于stack exchange,提问作者erionpc

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.01 00:43:13