首页 > 解决方案 > Terraform Azure Function App 部署 - 表示设置

问题描述

我正在尝试通过 Terraform 部署 Azure Function App

尝试表示函数应用设置时出现以下错误:

错误:azurerm_function_app.func-app-1::无效或未知键:always_on

错误:azurerm_function_app.func-app-1::无效或未知键:use_32_bit_worker_process

错误:azurerm_function_app.func-app-1::无效或未知键:websockets_enabled

以下是我正在使用的代码:

            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"

            }

            }

任何帮助,将不胜感激

谢谢

标签: azureterraform

解决方案


您需要在 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}"
}

在变量.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"
    }
}

推荐阅读