使用 terraform 部署 Azure powershell 函数应用程序时出现问题

Issue in deploying Azure powershell function app with terraform

我在使用 terraform 部署的 azure 函数应用程序 blob 触发器时遇到以下错误

D:\a\s\src\RequestProcessor.cs:第 196 行 2021-01-08T14:24:46.222 [Error] Executed 'Functions.BlobTrigger1' (Failed, Id=973f1e27-3dc2-43d3-9463-7cac64bf56b7, Duration=6625ms)Result: FailureException: Failed to install function app dependencies.错误:'在函数应用根文件夹中找不到 'requirements.psd1':C:\home\site\wwwroot.

我已经使用这个 https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/function_app 来创建 terraform 代码,通过使用上面的文档和 google 中的其他参考,我在 main.tf[=13= 中编写了以下代码]

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 函数应用程序设置 Python 版本,但我想对 Powershell 做同样的事情:

site_config {
    linux_fx_version = "PYTHON|3.9"
}

Terraform 文档对 Powershell Function Apps 的描述不明确。