首页 > 解决方案 > 参数“storage_connection_string”是必需的,但没有找到定义

问题描述

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

使用来自 Hasihcorp 的文档在这里找到。

但是,在运行时出现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"

设置了值的格式和引用,但我在这台计算机上没有代码,所以像这样发布它更有意义。

标签: azureazure-functionsterraformterraform-provider-azure

解决方案


这很可能是由于使用了过时版本的 azure 提供程序。例如,版本 2.0.0有一个必需的storage_connection_string. 在某些版本中已将其删除。

解决方案:升级您使用的提供商版本。您应该在某个地方声明要使用 azure 提供程序。在那个地方,您还应该指定版本约束,例如:

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

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


推荐阅读