Why do I need both APPINSIGHTS_INSTRUMENTATIONKEY and APPLICATIONINSIGHTS_CONNECTION_STRING in my Azure Function configuration?
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.
One important thing to note is that if APPINSIGHTS_INSTRUMENTATIONKEY is removed from the Azure Function's configuration, the "Logs" entry in the "Monitoring" section in the Azure portal does not show logs anymore and instead asks you again to connect to an Application Insights resource. If you do so, the portal recreates the APPINSIGHTS_INSTRUMENTATIONKEY config setting.
This seems like a bug in the Azure portal since metrics and logs do continue to be collected. Also, funny enough "Log stream" continues to work as well.