Question Details

No question body available.

Tags

c# open-telemetry azure-monitoring microsoft-entra-id azure-monitor

Answers (1)

April 30, 2025 Score: 0 Rep: 6,378 Quality: Low Completeness: 80%

No, you need to specify which Application Insights resource to use. It can be done either in code or through environment variable: https://learn.microsoft.com/en-us/azure/azure-monitor/app/opentelemetry-configuration?tabs=aspnetcore#connection-string

You can modify your code to include this line:

var builder = WebApplication.CreateBuilder(args);

// Add the OpenTelemetry telemetry service to the application. // This service will collect and send telemetry data to Azure Monitor. builder.Services.AddOpenTelemetry().UseAzureMonitor(options => { options.ConnectionString = ""; });

var app = builder.Build();

app.Run();

Or you can specify an environment variable (APPLICATIONINSIGHTSCONNECTIONSTRING) or appsettings.json config file. In this case your code will work as is.

Data will be sent only to specified Application Insights resource. If you need to send to two - it is possible through advanced configuration.