Soru

Zorluk: ZorConfigure Application Insights Instrumentation and Telemetry

You are configuring Application Insights telemetry for a C# .NET 8 console application. The application retrieves its configuration from an Azure App Configuration instance, which includes the Application Insights configuration. You write the following code to initialize telemetry:

csharp
var config = TelemetryConfiguration.CreateDefault();
var client = new TelemetryClient(config);
client.TrackTrace("Offline processing started.");

During testing, you verify that no telemetry data is transmitted to the Application Insights resource, and the application runs without throwing any exceptions.

Which of the following is the most likely root cause of the missing telemetry?

  1. The connection string was not explicitly assigned to the ConnectionString property of the TelemetryConfiguration object, and the APPLICATIONINSIGHTS_CONNECTION_STRING environment variable was not set.Cevap
  2. B
    The connection string is stored in Azure Key Vault, but the application's system-assigned managed identity lacks GET permissions via a Key Vault access policy, preventing the application from retrieving the connection string value.
  3. C
    The connection string is stored in Azure App Configuration as a Key Vault reference but uses an invalid syntax that lacks the @Microsoft.KeyVault prefix, preventing the configuration provider from resolving the secret.
  4. D
    The SDK was configured using the deprecated InstrumentationKey property, which is ignored by the modern telemetry channel in .NET 8, causing telemetry to be silently discarded.

Cevap

The connection string was not explicitly assigned to the ConnectionString property of the TelemetryConfiguration object, and the APPLICATIONINSIGHTS_CONNECTION_STRING environment variable was not set.
The correct option is that the connection string was not explicitly assigned to the configuration object and the environment variable was missing. When using the Application Insights SDK programmatically in .NET, TelemetryConfiguration.CreateDefault() searches for the APPLICATIONINSIGHTS_CONNECTION_STRING environment variable. If it is not found and the ConnectionString property is not set in code, the SDK initializes with an empty destination and silently drops all tracked traces, events, and metrics without throwing any runtime exceptions.

Adım Adım Çözüm

1
Inspect telemetry configuration initialization code.
Identify that TelemetryConfiguration.CreateDefault() is called without programmatically setting the ConnectionString property.
By default, TelemetryConfiguration.CreateDefault() looks for the APPLICATIONINSIGHTS_CONNECTION_STRING environment variable.
2
Check environment variable configuration.
Determine that the APPLICATIONINSIGHTS_CONNECTION_STRING environment variable is not defined in the host environment.
If neither the environment variable is set nor the property is assigned in code, the SDK is left unconfigured.
3
Analyze SDK telemetry transmission behavior under missing configuration.
Observe that the Application Insights SDK silently drops telemetry calls without throwing configuration exceptions.
The SDK is designed to fail silently to prevent telemetry configuration issues from crashing the primary application logic.

Anahtar Kavram

Application Insights SDK programmatic initialization requires a Connection String to be supplied either via TelemetryConfiguration.ConnectionString or the APPLICATIONINSIGHTS_CONNECTION_STRING environment variable.
Tahmini Süre:2m 0s
Bu soruyu puanla