Terraform Azure Function App Deployment - Representing settings

deploy azure function using terraform
azure deploy function app
terraform function app consumption plan
terraform azure app service plan
terraform azure app configuration
terraform azure function runtime version
azure rm app service
terraform application insights

I am trying to deploy an Azure Function App via Terraform

I am getting the following errors when trying to represent the Function App settings:

Error: azurerm_function_app.func-app-1: : invalid or unknown key: always_on

Error: azurerm_function_app.func-app-1: : invalid or unknown key: use_32_bit_worker_process

Error: azurerm_function_app.func-app-1: : invalid or unknown key: websockets_enabled

Below is the code i am using:

            resource "azurerm_function_app" "func-app-1" {
            name = "${var.func_app_1}"
            location = "${data.azurerm_resource_group.core-rg.location}"

            resource_group_name = "${data.azurerm_resource_group.core-rg.name}"

            app_service_plan_id = "${data.azurerm_app_service_plan.app-service-plan-1.id}"

            storage_connection_string = "${data.azurerm_storage_account.storage-account-1.primary_connection_string}"

            version                   = "~1"
            https_only                = "true"
            enabled                   = "true"
            always_on                 = "true"
            use_32_bit_worker_process = "false"
            websockets_enabled        = "true"
            client_affinity_enabled   = "false"

            app_settings {

            "FUNCTIONS_EXTENSION_VERSION" = "~1"

            "KeyVaultURI" = ""

            "WEBSITE_NODE_DEFAULT_VERSION" = "6.5.0"

            }

            }

Any help would be appreciated

Thank you


Please define the same under site_config. Please refer below code. You can add further

resource "azurerm_function_app" "prod" {
  name                      = "${var.function_app_name}"
  location                  = "${azurerm_resource_group.prod.location}"
  resource_group_name       = "${azurerm_resource_group.prod.name}"
  app_service_plan_id       = "${azurerm_app_service_plan.prod.id}"
  storage_connection_string = "${azurerm_storage_account.prod.primary_connection_string}"
  version                   = "~2"
  app_settings = {
    APPINSIGHTS_INSTRUMENTATIONKEY              = "${azurerm_application_insights.prod.instrumentation_key}"
    FUNCTIONS_EXTENSION_VERSION                 = "~2"
    FUNCTIONS_WORKER_RUNTIME                    = "dotnet"
    WEBSITE_CONTENTAZUREFILECONNECTIONSTRING    = "${azurerm_storage_account.prod.primary_connection_string}"
    WEBSITE_CONTENTSHARE                        = "${var.storage_account_name}"
  }
  site_config {
    always_on   = "true"
  }
}

Azure Resource Manager: azurerm_function_app, app_settings - (Optional) A key-value pair of App Settings. ip_restriction - (​Optional) A List of objects representing ip restrictions as defined below. NOTE User  Note: When integrating a CI/CD pipeline and expecting to run from a deployed package in Azure you must seed your app settings as part of terraform code for function app to be successfully deployed. Important Default key pairs : ( "WEBSITE_RUN_FROM_PACKAGE" = "" , "FUNCTIONS_WORKER_RUNTIME" = "node" (or python, etc), "WEBSITE_NODE_DEFAULT_VERSION" = "10.14.1" , "APPINSIGHTS_INSTRUMENTATIONKEY" = "" ).


I believe you need to add those values that are erroring in a site_config block as per the docs here : https://www.terraform.io/docs/providers/azurerm/d/app_service.html

App Service, When deploying an Azure Function to an App Service Plan, there are two erroneous application settings being added by default. I'm happy give this fix a go, I'm just not sure how to best represent the fix. APErebus added a commit to APErebus/terraform-provider-azurerm that referenced this issue on  These are the instructions for deploying a basic Azure Function app with TypeScript code from start to finish. Let’s first of all go through all the steps at a high-level: Get your environment in order. Create an Azure Function app. Create a Terraform module describing your infrastructure. Adjust the Azure Function app to produce a deployment


You need to define app settings in variables.tf

resource "azurerm_function_app" "func-app-1" {
            name = "${var.func_app_1}"
            location = "${data.azurerm_resource_group.core-rg.location}"

            resource_group_name = "${data.azurerm_resource_group.core-rg.name}"

            app_service_plan_id = "${data.azurerm_app_service_plan.app-service-plan-1.id}"

            storage_connection_string = "${data.azurerm_storage_account.storage-account-1.primary_connection_string}"

            version                   = "~1"
            https_only                = "true"
            enabled                   = "true"
            always_on                 = "true"
            use_32_bit_worker_process = "false"
            websockets_enabled        = "true"
            client_affinity_enabled   = "false"
            app_settings              = "${var.app_settings}"
}

In variables.tf

variable "app_settings" {
    description = "A key-value pair of App Settings"
    default     = {
        "FUNCTIONS_EXTENSION_VERSION" = "~1",
        "KeyVaultURI" = "",
        "WEBSITE_NODE_DEFAULT_VERSION" = "6.5.0"
    }
}

Deploying an Azure Function App with Terraform, In my current projects I'm actually using lots of Azure Functions and started to The provider configuration is quite simple and straight forward. to run Azure Functions: blob storage, app service plan and a function (maybe some code, too )​. If we need to apply the ipSecurityRestrictions or change the ftpsState of an Azure Function App at deployment time by using Terraform, we will see that these properties are not yet exposed by the


App Service Plan based Function App has erroneous application , Terraform is a cloud infrastructure automation tool made by DISCLAIMER: This post is purely a personal opinion, not representing or affiliating my employer's. As we provision both Azure Functions and Logic Apps throughout this Have a read of this post that how parameters and variables in ARM  resource_group_name - The name of the Resource Group where the Function App exists. » Attributes Reference The following attributes are exported: id - The ID of the Function App. app_service_plan_id - The ID of the App Service Plan within which to create this Function App. app_settings - A key-value pair of App Settings.


Deploy Azure Functions with Terraform - Dennis Bappert, The Terraform configuration files used in the course are all available in the Two​-Tier App Demo, See how to deploy a two-tier app in multiple The Cloud Academy Labs on Terraform demonstrate working with the AWS and Azure providers. value of a variable that stores a string representing the current environment. In previous articles (I, II) we’ve seen how to deploy an Azure Function App using the Azure CLI and the Azure Functions Core Tools. In this article we’ll see how to deploy it using Terraform. Prerequisites In order to follow this article you will need the .Net SDK 2.1, the Azure CLI and Terraform installed in your laptop/container/VM


Terraforming Azure PaaS, Automating your build and deployment workflow with GitHub Actions allows you to know how your Execute Terraform configuration and build Azure resources This is a file ending in .tfvars which represent variables that you pass in at runtime. Think of a resource like a coding method or a function. App settings reference for Azure Functions. 09/22/2018; 7 minutes to read +8; In this article. App settings in a function app contain global configuration options that affect all functions for that function app. When you run locally, these settings are accessed as local environment variables. This article lists the app settings that are