问题描述
我在使用 terraform 部署的 azure 函数应用程序 blob 触发器时遇到以下错误
D:\a\1\s\src\RequestProcessor.cs:line 196 2021-01-08T14:24:46.222 [错误] 执行“Functions.BlobTrigger1”(失败,Id=973f1e27-3dc2-43d3-9463-7cac64bf56b7,Duration=6625ms)失败。应用程序安装失败错误:在函数应用根文件夹中找不到“requirements.psd1”:C:\home\site\wwwroot。
我使用这个 https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/function_app 来创建 terraform 代码,通过使用上述文档和谷歌中的其他参考,我在 main.tf 中编写了以下代码
app_settings = {
FUNCTIONS_WORKER_RUNTIME = var.FUNCTIONS_WORKER_RUNTIME
FUNCTIONS_WORKER_RUNTIME_VERSION = var.FUNCTIONS_WORKER_RUNTIME_VERSION
在variable.tf中赋值如下
variable "FUNCTIONS_WORKER_RUNTIME"{
default = "PowerShell"
}
variable "FUNCTIONS_WORKER_RUNTIME_VERSION" {
default = "~7"
}
但仍然无法在应用中看到 PowerShell Core 版本。
解决方法
经过我的验证,您可以将 FUNCTIONS_WORKER_RUNTIME
的值设置为 "powershell"
而不是 "PowerShell"
并添加 version = "~3"
。它将自动安装函数应用依赖项 requirements.psd1
。
resource "azurerm_function_app" "example" {
name = "urewwwwfunctiona"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
app_service_plan_id = azurerm_app_service_plan.example.id
storage_account_name = azurerm_storage_account.example.name
storage_account_access_key = azurerm_storage_account.example.primary_access_key
app_settings = {
FUNCTIONS_WORKER_RUNTIME = "powershell"
FUNCTIONS_WORKER_RUNTIME_VERSION = "~7"
}
version = "~3"
}
,
您好,我可以使用 azurerm_function_app 在 Azure 中部署 Powershell 函数应用程序,但 Powershell 核心版本为空白。
我遵循了 Nancy Xiong 的建议,但没有成功:
resource "azurerm_function_app" "example" {
name = "functionapptest"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
app_service_plan_id = azurerm_app_service_plan.example.id
storage_account_name = azurerm_storage_account.example.name
storage_account_access_key = azurerm_storage_account.example.primary_access_key
version = "~3"
app_settings = {
FUNCTIONS_WORKER_RUNTIME = "powershell"
FUNCTIONS_WORKER_RUNTIME_VERSION = "~7"
}
}
我能够使用 linux_fx_version 为 Linux Function App 设置 Python 版本,但我想为 Powershell 设置相同的版本:
site_config {
linux_fx_version = "PYTHON|3.9"
}
Terraform 文档对 Powershell 函数应用程序不清楚。