Soru

Zorluk: OrtaConfigure Application Insights Instrumentation and Telemetry

An offline data processing utility is written in C# and runs on an Azure Linux VM. You configure telemetry by writing the following code block to log lifecycle events:

csharp
var configuration = new TelemetryConfiguration();
var client = new TelemetryClient(configuration);
client.TrackEvent("JobStarted");

During testing, you notice that no events are captured in the Application Insights logs. You must update the code to ensure telemetry is transmitted correctly.

Which TWO actions should you take to resolve this issue? (Select TWO.)

  1. Initialize the telemetry configuration object using TelemetryConfiguration.CreateDefault() instead of new TelemetryConfiguration().Cevap
  2. Configure the Application Insights connection string by assigning it to the ConnectionString property of the TelemetryConfiguration instance.Cevap
  3. C
    Assign the instrumentation key directly to the deprecated InstrumentationKey property of the TelemetryConfiguration instance.
  4. D
    Retrieve the connection string from Azure Key Vault and configure the VM's user-assigned managed identity with only Key Vault decrypt permissions.

Cevap

Initialize the telemetry configuration object using TelemetryConfiguration.CreateDefault() and configure the Application Insights connection string by assigning it to the ConnectionString property of the TelemetryConfiguration instance.
To manually configure the Application Insights SDK in a non-web application, you must use TelemetryConfiguration.CreateDefault() to build the default telemetry pipeline, including the channel and default processors. Additionally, you must specify the ConnectionString of the Application Insights resource so the SDK knows where to send the telemetry.

Adım Adım Çözüm

1
Change the initialization of TelemetryConfiguration to use the static CreateDefault() factory method.
The TelemetryConfiguration object is instantiated with the standard channel (InMemoryChannel) and default pipeline components.
The parameterless constructor of TelemetryConfiguration does not create the necessary background pipeline (such as the transmission channel) to serialize and send data.
2
Set the ConnectionString property on the configuration object with the connection string retrieved from your Azure environment.
The SDK is configured with the correct ingestion endpoints.
Azure Monitor requires connection strings to handle telemetry routing, endpoint overrides, and authentication securely.

Anahtar Kavram

Manual initialization of Application Insights SDK using TelemetryConfiguration and TelemetryClient in non-web environments.
Tahmini Süre:1m 30s
Bu soruyu puanla