azure - Terraform 不允许使用名称更新 AppSetting 时出错

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

使用 Terraform 更新 Azure 应用服务应用设置时,我们收到以下错误:

{"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

最佳答案

不确定,我没有找到文档来显示 Azure 应用服务中的应用设置的限制。但据我所知,操作系统有这方面的限制。对于Linux,您无法设置名称包含-的环境变量。但在 Windows 中,不存在 - 的限制。一般来说,字母和数字在两个系统中都没有问题。

关于azure - Terraform 不允许使用名称更新 AppSetting 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55956292/

相关文章:

powershell - Runbook 中的 Azure DSC 配置

azure - 限制对暂存和开发插槽的访问

azure - 覆盖 Azure 网站中的 applicationSettings "MySite.Properties.Settings.MySetting"

spring-boot - 如何将简单的Java Spring启动应用程序部署到Azure Web Job中?

amazon-web-services - 如何将stepfunctionexecutionId解析为SageMaker批量转换作业名称?

azure - 网络发布完成后不再打开网站 VS 2022

c# - 从 Blob Azure 下载重定向错误

asp.net-core - 在 ASP.NET Core 中禁用分块

google-cloud-platform - 带有列表抛出错误的 Terraform 多级 map

database - Liquibase 和 Terraform 最佳实践