参数 "storage_connection_string" 是必需的,但没有找到定义

The argument "storage_connection_string" is required, but no definition was found

我目前正在尝试使用 Terraform 设置 Azure Function 应用程序。

使用 Hasihcorp 的文档发现 here

然而,当 运行 a terraform plan 我收到以下错误:The argument "storage_connection_string" is required, but no definition was found.

根据文档,没有这样的有效参数,因此我没有包含它。我在四处寻找时只找到了一个条目,这只是一个问题,没有任何回应。我不太精通 Azure,所以不知道我是否需要 storage_connection_string,或者是 API 搞乱了我。

资源片段:

resource "azurerm_function_app" "this" {
  name = "function-name"
  resource_group_name = "resource-group"
  location = "location"
  app_service_plan_id = "id"
  storage_account_name = "name"
  storage_account_access_key = "key"

值的格式设置和引用已设置,但我在这台计算机上没有代码,因此 post 像这样更有意义。

这很可能是因为使用了过时版本的 azure 提供程序。例如。 version 2.0.0 有一个必需的 storage_connection_string。在 一些 版本中被删除了。

解决方案:升级您使用的提供程序版本。您应该在某个地方声明要使用 azure 提供程序。在那个地方你也应该指定一个 version constraint,例如:

terraform {
  required_providers {
    azure = {
      version = "~> 2.40.0"
    }
  }
}

或者您应该只查看与您当前的提供者 + terraform 版本相匹配的文档。