Optimizely DXP & Application Insights | Instrumentation Key VS Connection String

Posted on February 17, 2023

You might be aware of the news, Microsoft is deprecating usage of the Instrumentation key–based data injestion. It has been almost one year since its announcement, but it made me thing about one thing while working with the solution of one of our clients: Optimizely DXP (Digital Experience Cloud).

When a client is subscribing to DXP, they are entitled to have a fully managed infrastructure in the Cloud to host their application, including 3 different environments:

  • Integration
  • PreProduction
  • Production

It's important to know that, for each environment, a different database and most notably Application Insights instance is used. This in fact the reason learning about the announcement of Microsoft made me think, but what if we're using the Connection String instead of the Instrumentation Key inside my solution?

So, some of you are already aware that we're able to view the configuration of the App Service of Integration. That lead me to find that currently speaking, only the environment variable APPINSIGHTS_INSTRUMENTATIONKEY is being used to configure the link between your application and Application Insights. Assuming this is the same setting for all environments, I realized that I cannot have a connection string configured on my local development environment - And anyway, Microsoft is pretty much straight forward about that:

Don't use both APPINSIGHTS_INSTRUMENTATIONKEY and APPLICATIONINSIGHTS_CONNECTION_STRING. Use of APPLICATIONINSIGHTS_CONNECTION_STRING is recommended.

Even though they recommend usage of a connection string, we cannot, because DXP environments are configured using the instrumentation key. So, long story short, don't use the connection string on your development machine, or at least, remove it using transformations during the deployment. If you keep using a connection string, you will have trouble with your telemetry data - Either everything will go inside your development App Insights, or your app might simply trace nothing anymore. I did not test my previous statement, but I'm confident this is what will happen.