ApplicationInsights-dotnet icon indicating copy to clipboard operation
ApplicationInsights-dotnet copied to clipboard

console app application insight logging is not working

Open ruonan0509 opened this issue 10 months ago • 3 comments

since Application Insights “Instrumentation Keys” are Sunsetting on March 31, 2025, i am trying to convert current applicationInsights config from Instrumentation Key to Connection String

current startup:

public void ConfigureServices(IServiceCollection services) => services .AddApplicationInsightsTelemetryWorkerService("00000000-0000-0000-0000-000000000000");

changed to

public void ConfigureServices(IServiceCollection services) => services .AddApplicationInsightsTelemetryWorkerService(options => options.ConnectionString = "InstrumentationKey="00000000-0000-0000-0000-000000000000");

but the new code is not logging anything to the same AI transaction logging. am I missing anything? thanks!

ruonan0509 avatar Jan 16 '25 23:01 ruonan0509

Make sure you copy the ConnectionString verbatim from your Application Insights resource. If that's not working, you can collect SDK logs to identify any errors within the SDK

TimothyMothra avatar Jan 16 '25 23:01 TimothyMothra

thank you @TimothyMothra getting back to me here is my AI

Image

the connection string is very long, shall i copy the whole thing or just InstrumentationKey=xxx part? and also where i can find the SDK logs? thank you!

ruonan0509 avatar Jan 16 '25 23:01 ruonan0509

Yes, full string. The SDK needs those Endpoint values.

Self diagnostics would be the easiest way to collect internal logs: https://github.com/microsoft/ApplicationInsights-dotnet/tree/main/troubleshooting/ETW#self-diagnostics

TimothyMothra avatar Jan 17 '25 00:01 TimothyMothra

working with the InstrumentationKey is depricated. You should work with the connectionstring InstrumentationKey=xxx;IngestionEndpoint=xxx;LiveEndpoint=xxx;ApplicationId=xxx

https://learn.microsoft.com/en-us/azure/azure-monitor/app/connection-strings

On March 31, 2025, support for instrumentation key ingestion will end. Instrumentation key ingestion will continue to work, but we'll no longer provide updates or support for the feature. Transition to connection strings to take advantage of new capabilities.

            services.AddApplicationInsightsTelemetryWorkerService(options =>
            {
                // default is EnvironmentVariable "APPLICATIONINSIGHTS_CONNECTION_STRING"
                // so we overwrite with the appsettings
                options.ConnectionString = configuration.GetValue<string>("ApplicationInsights:ConnectionString");
            });

JJong-nl avatar Jul 29 '25 11:07 JJong-nl