CodexBloom - Programming Q&A Platform

Terraform does not properly manage Azure Function App settings when using azurerm_function_app_setting

πŸ‘€ Views: 1 πŸ’¬ Answers: 1 πŸ“… Created: 2025-06-05
terraform azure azure-function-app HCL

I'm having a hard time understanding I'm confused about I've searched everywhere and can't find a clear answer. I'm currently working on a Terraform configuration to deploy an Azure Function App, but I'm facing issues with managing the application settings. I've defined the settings using the `azurerm_function_app_settings` resource, but after applying the configuration, I noticed that the settings are not being updated as expected. Instead, it seems like Terraform is trying to recreate the entire Function App rather than just updating the settings. Here’s a snippet of my Terraform code: ```hcl resource "azurerm_function_app" "example" { name = "my-function-app" location = "West US" resource_group_name = azurerm_resource_group.example.name app_service_plan_id = azurerm_app_service_plan.example.id storage_account_name = azurerm_storage_account.example.name storage_account_access_key = azurerm_storage_account.example.primary_access_key version = "~2" } resource "azurerm_function_app_settings" "example_settings" { function_app_id = azurerm_function_app.example.id settings = { "AzureWebJobsStorage" = azurerm_storage_account.example.primary_connection_string "FUNCTIONS_WORKER_RUNTIME" = "dotnet" } } ``` After running `terraform apply`, I see the following output: ``` Plan: 1 to add, 0 to change, 1 to destroy. ``` I’ve tried running `terraform refresh` to update the state, but the issue persists. I've also ensured that the application settings are correctly configured in the Azure Portal, and I can confirm that they are being manually changed there without any issues. I've verified that I'm using Terraform version 1.1.9 and the AzureRM provider version 2.86.0. Is there a known issue with managing function app settings in this version? How can I force Terraform to update the settings without attempting to recreate the function app? Any guidance would be greatly appreciated! Is there a better approach? For context: I'm using Hcl on CentOS. Has anyone else encountered this?