首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过带有应用程序设置的terraform部署azure功能时的问题

通过带有应用程序设置的terraform部署azure功能时的问题
EN

Stack Overflow用户
提问于 2022-06-15 11:04:24
回答 1查看 1.3K关注 0票数 3

我遵循这个docs页面来部署带有应用程序设置应用程序的azure函数。

我的terraform文件看起来像:

代码语言:javascript
复制
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命令部署它时,我会得到这个错误。

代码语言:javascript
复制
│ 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.
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-06-16 12:07:29

Terraform AzureRM提供程序的特定版本支持AzureRM。这些版本都有可用的https://learn.microsoft.com/en-us/azure/developer/terraform/provider-version-history-azurerm。我使用了3.3.0提供程序版本,它正按预期的方式为我工作,而且您也不能配置site_config.Its值的值,这将根据应用此配置的结果自动确定,同样,您也可以签入更新的Terraform 文档

main.tf

代码语言:javascript
复制
 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"
      }
    
    }

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72630228

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档