Search code examples
azureazure-web-app-serviceterraformterraform-provider-azure

Error updating AppSetting with name is not allowed from Terraform


While updating an Azure App Service App Setting with Terraform we're getting the following error:

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

However if we add it via the portal manual it works totally fine: enter image description here

I'm guessing it's something to do with the 0 or - but how do we escape these?

The Terraform code is pretty simple but here is a failing example:

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

Dropping into the bash terminal in kudo and running printenv shows that setting it manually removes the -:

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

Solution

  • I ran into this error with linux_function_app and my problem seemed to be that I had dashes in my app_setting. I changed them to Underscores and it worked.

    I'm not aware that there was a restriction on using dashes in the app setting parameter names tho. I've used both dashes and underscores before.