使用 Terraform 更新 Azure 应用服务应用设置时,我们收到以下错误:
{"Message":"AppSetting with name 'HEALTHCHECKS-UI_HEALTHCHECKS_0_NAME' is not allowed."}
我猜这与 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/