简体   繁体   English

Terraform Azure Function App 部署 - 表示设置

[英]Terraform Azure Function App Deployment - Representing settings

I am trying to deploy an Azure Function App via Terraform我正在尝试通过 Terraform 部署 Azure Function App

I am getting the following errors when trying to represent the Function App settings:尝试表示 Function App 设置时出现以下错误:

Error: azurerm_function_app.func-app-1: : invalid or unknown key: always_on错误:azurerm_function_app.func-app-1::无效或未知密钥:always_on

Error: azurerm_function_app.func-app-1: : invalid or unknown key: use_32_bit_worker_process错误:azurerm_function_app.func-app-1::无效或未知密钥:use_32_bit_worker_process

Error: azurerm_function_app.func-app-1: : invalid or unknown key: websockets_enabled错误:azurerm_function_app.func-app-1::无效或未知密钥: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谢谢

You need to define app settings in variables.tf您需要在 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在变量.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"
    }
}

我相信您需要根据此处的文档添加在 site_config 块中出错的值: https : //www.terraform.io/docs/providers/azurerm/d/app_service.html

Please define the same under site_config.请在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"
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM