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

Terraform AzureRM配置Function App的host.json日志级别无文档支持

Configure Azure Function App host.json Log Level to Debug via Terraform

Got it, I know exactly where you're stuck here. The trick is that Terraform's AzureRM provider has a dedicated parameter for configuring the host.json file directly—you don't need to mess with app settings for this.

Here's how to implement your desired configuration:

You can use the host_json parameter in the azurerm_function_app resource. This parameter accepts a JSON-encoded string (we use Terraform's jsonencode() function to handle the conversion cleanly) that defines the full content of your host.json file.

Add this to your existing azurerm_function_app block, alongside your existing app_settings:

resource "azurerm_function_app" "your_function_app" {
  name                       = "your-function-app-name"
  resource_group_name        = azurerm_resource_group.your_rg.name
  location                   = azurerm_resource_group.your_rg.location
  app_service_plan_id        = azurerm_app_service_plan.your_plan.id
  storage_account_name       = azurerm_storage_account.your_storage.name
  storage_account_access_key = azurerm_storage_account.your_storage.primary_access_key

  # Your existing app_settings configuration
  app_settings = {
    "FUNCTIONS_WORKER_RUNTIME" = "python" # Adjust to your runtime (node/dotnet/etc.)
    # ... other existing settings ...
  }

  # Configure host.json with Debug log level
  host_json = jsonencode({
    "version": "2.0",
    "functionTimeout": "00:10:00",
    "logging": {
      "logLevel": {
        "default": "Debug"
      }
    }
  })
}

Key Notes:

  • The host_json parameter replaces the entire host.json file for your Function App, so make sure to include all existing configuration values you need (like version and functionTimeout from your example) alongside the logging settings.
  • When you run terraform apply, Terraform will automatically update the host.json file in your Function App to match this configuration—no manual changes needed in the Azure Portal.
  • This works for all Function App runtimes (Python, Node.js, .NET, etc.) since host.json is a runtime-agnostic configuration file.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.13 07:30:16