Terraform Azure Function App Deployment - Representing Settings
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...
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
3 Answers
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"
}
}
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"
}
}
I believe you need to add those values that are erroring in a site_config block as per the docs here :