Search code examples
azureazure-functionsazure-application-insights

Why do I need both APPINSIGHTS_INSTRUMENTATIONKEY and APPLICATIONINSIGHTS_CONNECTION_STRING in my Azure Function configuration?


APPINSIGHTS_INSTRUMENTATIONKEY contains the instrumentation key for Application Insights.

APPLICATIONINSIGHTS_CONNECTION_STRING contains the instrumentation key for Application Insights prefixed with InstrumentationKey=.

That seems pointless unless each value enables certain features with Application Insights.


Solution

  • Looking at the release notes for SDK Version 2.0.12998:

    App Insights configuration will use the APPLICATIONINSIGHTS_CONNECTION_STRING app setting if it is set (APPINSIGHTS_INSTRUMENTATIONKEY is the fallback and continues to work as-is).

    Furthermore, if you read the documentation for App Insights Connection String, you will notice that when you use connection string, you can specify custom endpoints. This is not possible if you just specify the instrumentation key. In that case, SDK will connect to default endpoints.