簡體   English   中英

使用應用程序設置通過 terraform 部署 azure 功能的問題

[英]Issue in deploying azure function through terraform with app settings

我正在關注此文檔頁面以使用應用程序設置部署 azure 功能https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/function_app

我的 terraform 文件如下所示:

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

provider "azurerm" {
}
resource "azurerm_resource_group" "example" {
  name     = "azure-functions-test-rg"
  location = "West Europe"
}

resource "azurerm_storage_account" "example" {
  name                     = "funcdemo123shafiq"
  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

  sku {
    tier = "Standard"
    size = "S1"
  }
}

resource "azurerm_function_app" "example" {
  name                       = "test-azure-shafiq123"
  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
  os_type                    = "linux"
  version                    = "~4"

  app_settings {
    FUNCTIONS_WORKER_RUNTIME = "python"
    TESTING_KEY              = "TESTING_VALUE"
  }

  site_config {
    linux_fx_version = "python|3.9"
  }
}

當嘗試通過terraform apply命令部署它時,我收到了這個錯誤。

│ Error: Unsupported block type
│
│   on main.tf line 46, in resource "azurerm_function_app" "example":
│   46:   app_settings {
│
│ Blocks of type "app_settings" are not expected here. Did you mean to define argument "app_settings"? If so, use the equals sign to assign it a value.

特定版本的 Terraform app_setting提供程序支持 app_setting。 這些版本有可用的錯誤修復 我使用了3.3.0提供程序版本,它按預期為我工作,而且您無法配置site_config的值。它的值將根據應用此配置的結果自動決定,同樣您可以簽入更新的Terraform 的文檔

主文件

 terraform {
      required_providers {
        azurerm = {
          source  = "hashicorp/azurerm"
          version = "3.3.0"
        }
      }
    }
    
    provider "azurerm" {
        features{}
    }
    data "azurerm_resource_group" "example" {
      name     = "v-rXXXXXree"
      #location = "West Europe"
    }
    
    resource "azurerm_storage_account" "example" {
      name                     = "funcdemo123shafiq4535"
      resource_group_name      = data.azurerm_resource_group.example.name
      location                 = data.azurerm_resource_group.example.location
      account_tier             = "Standard"
      account_replication_type = "LRS"
    }
    
    resource "azurerm_service_plan" "example" {
      name                = "azure-functions-test-service-plan1"
      location            = data.azurerm_resource_group.example.location
      resource_group_name = data.azurerm_resource_group.example.name
      os_type             = "Linux"
      sku_name            = "Y1"
    }
    
    resource "azurerm_linux_function_app" "example" {
      name                       = "test-azure-shafi4353"
      location                   = data.azurerm_resource_group.example.location
      resource_group_name        = data.azurerm_resource_group.example.name
      service_plan_id            =  azurerm_service_plan.example.id
      storage_account_name       = azurerm_storage_account.example.name
      storage_account_access_key = azurerm_storage_account.example.primary_access_key
      #os_type                    = "linux"
      #version                    = "~3"
    
      app_settings={
        FUNCTIONS_WORKER_RUNTIME = "python"
        TESTING_KEY              = "TESTING_VALUE"
      }
    
      site_config {
        #linux_fx_version = "python|3.9"
      }
    
    }

在此處輸入圖像描述

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM