How can I configure Genaral setting like always on and dotnet version for an Azure Function(in dotnet 8) App using Terraform?

ravi patel 0 Reputation points
2024-06-11T16:49:13.8366667+00:00
i have tried below code

resource "azurerm_function_app" "example" {
    name                      = var.function_app_name
    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                   = "~3"
    os_type                   = "linux"
    site_config {
         always_on = true
        linux_fx_version = "DOTNET|5.0"
    }
}
also tried this i have tried 
 site_config {
         always_on = true
       dotnet_framework_version = "8.0"
    }  but none of them are working
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,911 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Dan Rios 2,020 Reputation points MVP
    2024-06-12T08:50:59.9766667+00:00

    I'm not sure that resource provider is the current Terraform supported one. The Terraform HashiCorp docs point to this:

    All the information is listed here for the site_config variables: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/linux_function_app

    "A site_config block supports the following:

    • always_on - (Optional) If this Linux Web App is Always On enabled. Defaults to false."

    Using this provider instead:

    resource "azurerm_linux_function_app"
    

    Here's an example site_config:

      site_config {
        always_on			= "true"
        ftps_state          = "Disabled"
        http2_enabled       = true
        minimum_tls_version = "1.2"
    
        application_stack {
          dotnet_version              = "8.0"
        }
    }
    

    Hopefully that will then solve the issue. If it does, please mark this as the accepted answer.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.