I am confused. As clearly published by Microsoft, Classic Application Insights is retired as of today.
That is unfortunate but not the end of the world. There is an alternative: log analytics workspace. So how to do my logging now? Well, I found an answer here.
However, this alternative approach relies on the well-known instrumentation key. This is going to be retired in approximately a year. So that is not very future proof, is it?
So how should I do my logging to (to log analytics workspace) without relying on deprecated NuGet packages, deprecated technologies or "retirement announced" technology?
Please just give me a C# example of how to do this nowadays.
Just make sure you use an up to date version of the AI Skd. Then, connect to your workspace based Application Insights resource using the connection string instead of the instrumentation key. It is al explained in the docs:
Put the connection string in the app settings:
and inject the SDK:
We have migrated some classic AI resources to workspace based AI resources. It didn't cause much trouble as we just had to change the InstrumentationKey to the ConnectionString in the settings file or update our code to set the connection string instead of the instrumentation key:
There is not much to it really.
If you still have AI resources that have to be updated go to that resource, click the warning message and follow the steps. No changes have to be done to the configuration of the applications sending telemetry when it comes to moving away from the classic to the workspace based resources:
or visit the docs regarding the migration.