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_jsonparameter replaces the entirehost.jsonfile for your Function App, so make sure to include all existing configuration values you need (likeversionandfunctionTimeoutfrom your example) alongside the logging settings. - When you run
terraform apply, Terraform will automatically update thehost.jsonfile 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.jsonis a runtime-agnostic configuration file.
内容的提问来源于stack exchange,提问作者Cosmin Cucu
相关产品推荐
相关产品推荐

