Terraform不允许错误更新名称的AppSetting

时间:2019-05-02 16:03:42

标签: azure azure-web-sites terraform azure-web-app-service terraform-provider-azure

在使用Terraform更新Azure App Service应用设置时,出现以下错误:

{"Message":"AppSetting with name 'HEALTHCHECKS-UI_HEALTHCHECKS_0_NAME' is not allowed."}

但是,如果我们通过门户网站手册添加它,则完全可以正常工作: enter image description here

我猜这与0-有关,但是我们如何逃避这些问题呢?

Terraform代码非常简单,但这是一个失败的示例:

resource "azurerm_resource_group" "test" {
  name     = "example-resources"
  location = "West Europe"
}

resource "azurerm_app_service_plan" "test" {
  name                = "example-appserviceplan"
  location            = "${azurerm_resource_group.test.location}"
  resource_group_name = "${azurerm_resource_group.test.name}"

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

resource "azurerm_app_service" "test" {
  name                = "example-app-service"
  location            = "${azurerm_resource_group.test.location}"
  resource_group_name = "${azurerm_resource_group.test.name}"
  app_service_plan_id = "${azurerm_app_service_plan.test.id}"

  site_config {
    dotnet_framework_version = "v4.0"
    scm_type                 = "LocalGit"
  }

  app_settings = {
    "HEALTHCHECKSUI_HEALTHCHECKS_0_NAME"  = "Self"
    "HEALTHCHECKSUI_HEALTHCHECKS_0_URI"   = "https://${var.environment_name}-example-app-service/health-api"
  }
}

以kudo拖放到bash终端并运行printenv显示手动设置会删除-

HEALTHCHECKSUI_HEALTHCHECKS_0_NAME=https://example-app-service.azurewebsites.net/health-api

2 个答案:

答案 0 :(得分:0)

不确定,我找不到文档来显示此限制对Azure App Service中的应用程序设置。但据我所知,操作系统具有这一局限性。对于Linux,不能使用名称包含-设置环境变量。但是在Windows中,-的限制不存在。通常,在两个系统中字母和数字都没有问题。

答案 1 :(得分:0)

从环境变量名称中删除-(破折号)。会很好

例如:Test-Pass-> TestPass