Reputation: 62886
appsettings.json allows us to specify hierarchical settings:
"ApplicationInsights": {
"InstrumentationKey": "..."
}
In code they are consumed like this - config["ApplicationInsights:InstrumentationKey"]
However, trying to provide ApplicationInsights:InstrumentationKey
in an app service terraform configuration:
app_settings = {
"ApplicationInsights:InstrumentationKey" = data.azurerm_application_insights.instance.instrumentation_key
}
Results in the following error message:
Error: Error updating Application Settings for App Service "app505-dfpg-qa2-web-eastus2-gateway-apsvc": web.AppsClient#UpdateApplicationSettings: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="BadRequest" Message="AppSetting with name 'ApplicationInsights:InstrumentationKey' is not allowed." Details=[{"Message":"AppSetting with name 'ApplicationInsights:InstrumentationKey' is not allowed."},{"Code":"BadRequest"},{"ErrorEntity":{"Code":"BadRequest","ExtendedCode":"04072","Message":"AppSetting with name 'ApplicationInsights:InstrumentationKey' is not allowed.","MessageTemplate":"AppSetting with name '{0}' is not allowed.","Parameters":["ApplicationInsights:InstrumentationKey"]}}]
By the looks of it, this Azure complaining, not terraform.
So, how can it be done, if at all?
EDIT 1
Please, note this is just an example. I can equally well ask for the following hierarchical setting:
"YabaDabaDoo": {
"YogiBear": "..."
}
How do we provide it in the App Service configuration?
Upvotes: 3
Views: 3078
Reputation: 28284
As the error indicates, AppSetting with name 'ApplicationInsights:InstrumentationKey' is not allowed. An Azure Function or Azure app service is associated with an Application Insights instance by adding the Instrumentation Key to the App Settings of the Azure application. You should use
app_settings {
"APPINSIGHTS_INSTRUMENTATIONKEY" = "${data.azurerm_application_insights.instance.instrumentation_key}"
}
You could get more details in this example.
Upvotes: 3