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

Azure Linux Web App部署报错:无法配置site_config.0.linux_fx_version

Azure Linux Web App Terraform部署报错原因分析

你使用Terraform部署容器化Azure Linux Web App时,编写的代码如下:

resource "azurerm_linux_web_app" "example" {
      name                = "test123-webapp"
      location            = azurerm_resource_group.example.location
      resource_group_name = azurerm_resource_group.example.name
      service_plan_id     = azurerm_service_plan.example.id
    
      site_config {
        linux_fx_version                        = "DOCKER|mcr.microsoft.com/appsvc/staticsite:latest"
        container_registry_use_managed_identity = true
        always_on                               = true
      }
    
      app_settings = {
        "DOCKER_REGISTRY_SERVER_URL"      = "https://${azurerm_container_registry.example.login_server}"
        "DOCKER_REGISTRY_SERVER_USERNAME" = azurerm_container_registry.example.admin_username
        "DOCKER_REGISTRY_SERVER_PASSWORD" = azurerm_container_registry.example.admin_password
      }
}

执行时出现以下错误:

│ Error: Value for unconfigurable attribute
│ 
│   with azurerm_linux_web_app.example,
│   on webapp.tf line 35, in resource "azurerm_linux_web_app" "example":
│   35:     linux_fx_version = "DOCKER|mcr.microsoft.com/appsvc/staticsite:latest"
│
│ Can't configure a value for "site_config.0.linux_fx_version": its value will be decided automatically based on the result of applying this configuration.

报错原因

在你使用的azurerm provider v3.112.0(以及v3.x系列多数新版本)中,azurerm_linux_web_app资源的site_config.linux_fx_version字段已被标记为自动计算属性,不再支持手动赋值。

当配置了容器注册表相关的app_settings(比如DOCKER_REGISTRY_SERVER_URL这类参数),或者启用了container_registry_use_managed_identity时,Terraform会自动根据这些配置生成对应的linux_fx_version值,无需手动指定。这是provider更新后的逻辑变化,和Azure门户手动配置的逻辑不同——门户允许手动设置,但Terraform现在强制由provider自动推导该字段。

解决方法

直接删除site_config块中的linux_fx_version配置项即可,修改后的代码如下:

resource "azurerm_linux_web_app" "example" {
      name                = "test123-webapp"
      location            = azurerm_resource_group.example.location
      resource_group_name = azurerm_resource_group.example.name
      service_plan_id     = azurerm_service_plan.example.id
    
      site_config {
        container_registry_use_managed_identity = true
        always_on                               = true
      }
    
      app_settings = {
        "DOCKER_REGISTRY_SERVER_URL"      = "https://${azurerm_container_registry.example.login_server}"
        "DOCKER_REGISTRY_SERVER_USERNAME" = azurerm_container_registry.example.admin_username
        "DOCKER_REGISTRY_SERVER_PASSWORD" = azurerm_container_registry.example.admin_password
      }
}

执行terraform apply时,provider会自动生成正确的linux_fx_version值,和你在门户看到的DOCKER|mcr.microsoft.com/appsvc/staticsite:latest一致。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.19 01:01:04