gpt4 book ai didi

azure - Terraform 部署的 azure 函数无法与 FUNCTIONS_WORKER_RUNTIME python 设置一起使用

转载 作者:行者123 更新时间:2023-12-03 06:50:21 28 4
gpt4 key购买 nike

当设置 FUNCTIONS_WORKER_RUNTIME = python 应用设置时,Azure Function App 显示“服务不可用。”(将此设置注释掉后,函数会显示“Your Functions 4.0 app is启动并运行”)。

据我了解,如果没有此设置,则不会安装requirements.txt,因此函数会返回错误(从日志中:没有名为“azure.storage”的模块...)。

我的 terraform Azure 函数代码:

resource "azurerm_linux_function_app" "function_app" {
name = "${var.name}fa"
resource_group_name = var.resource_group.name
location = var.resource_group.location

storage_account_name = var.storage_account.name
storage_account_access_key = var.storage_account.primary_access_key
service_plan_id = var.service_plan.id

site_config {
application_insights_key = azurerm_application_insights.ai.instrumentation_key
application_insights_connection_string = azurerm_application_insights.ai.connection_string
}

app_settings = {
APPINSIGHTS_INSTRUMENTATIONKEY = azurerm_application_insights.ai.instrumentation_key
SCM_DO_BUILD_DURING_DEPLOYMENT = true
FUNCTIONS_WORKER_RUNTIME = "python"
}
}

最佳答案

正确的配置应该如下所示:

resource "azurerm_linux_function_app" "function_app" {
name = "${var.name}fa"
resource_group_name = var.resource_group.name
location = var.resource_group.location

storage_account_name = var.storage_account.name
storage_account_access_key = var.storage_account.primary_access_key
service_plan_id = var.service_plan.id

site_config {
application_insights_key = azurerm_application_insights.ai.instrumentation_key
application_insights_connection_string = azurerm_application_insights.ai.connection_string
application_stack {
python_version = "3.9"
}
}

app_settings = {
APPINSIGHTS_INSTRUMENTATIONKEY = azurerm_application_insights.ai.instrumentation_key
SCM_DO_BUILD_DURING_DEPLOYMENT = true
}
}

关于azure - Terraform 部署的 azure 函数无法与 FUNCTIONS_WORKER_RUNTIME python 设置一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73756136/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com