【问题标题】:error when trying to create azure functions - consumption plan with terraform尝试创建天蓝色函数时出错 - 使用 terraform 的消费计划
【发布时间】:2021-06-12 07:35:14
【问题描述】:

我正在关注官方示例:

terraform {
  required_providers {
    azurerm = {
      source = "hashicorp/azurerm"
      version = "2.51.0"
    }
  }
}

provider "azurerm" {
  # Configuration options
}

resource "azurerm_resource_group" "example" {
  name     = "azure-functions-cptest-rg"
  location = "West Europe"
}

resource "azurerm_storage_account" "example" {
  name                     = "functionsapptestsa"
  resource_group_name      = azurerm_resource_group.example.name
  location                 = azurerm_resource_group.example.location
  account_tier             = "Standard"
  account_replication_type = "LRS"
}

resource "azurerm_app_service_plan" "example" {
  name                = "azure-functions-test-service-plan"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  kind                = "FunctionApp"

  sku {
    tier = "Dynamic"
    size = "Y1"
  }
}

resource "azurerm_function_app" "example" {
  name                       = "test-azure-functions"
  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
}

https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/function_app#example-usage-in-a-consumption-plan

当我运行 terraform validate 时,它​​通过了,但是当我尝试应用它时说:

此处不应使用名为“storage_account_access_key”的参数。

此处不应使用名为“storage_account_name”的参数。

有什么线索吗?

【问题讨论】:

    标签: azure terraform terraform-provider-azure


    【解决方案1】:

    您需要升级您的 azure 提供程序。支持storage_account_namestorage_account_access_keywas added in version 2.7

    当前版本是 2.51。

    您可以尝试使用以下方式升级:

    terraform init -upgrade
    

    没有-upgrade TF 将不会有upgrade 现有模块:

    使用已安装的模块重新运行 init 将安装自上次 init 以来添加到配置中的所有模块的源代码,但不会更改任何已安装的模块

    【讨论】:

    • 谢谢,但也没有用。我相信这是他们在这个版本中打破的东西
    【解决方案2】:

    我尝试了相同的代码,它对我有用

    Terraform v0.14.7
    + provider registry.terraform.io/hashicorp/azurerm v2.51.0
    

    您可以考虑升级您的 terraform 版本。见Download Terraform

    【讨论】:

      猜你喜欢
      • 2020-03-31
      • 2019-03-18
      • 1970-01-01
      • 1970-01-01
      • 2014-10-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多