Soru

Zorluk: ZorConfigure Application Insights Instrumentation and Telemetry

You are developing a C# .NET 8 Worker Service application that will be hosted in Azure Container Apps. You need to configure the Application Insights SDK to collect telemetry from this non-web application. You must use the latest Azure-recommended configuration practices and avoid deprecated properties.

Which two actions should you perform? (Select TWO.)

  1. Call builder.Services.AddApplicationInsightsTelemetryWorkerService(); in the Program.cs file.Cevap
  2. Configure an environment variable named APPLICATIONINSIGHTS_CONNECTION_STRING with the Application Insights connection string.Cevap
  3. C
    Call builder.Services.AddApplicationInsightsTelemetry(); in the Program.cs file.
  4. D
    Configure an environment variable named APPINSIGHTS_INSTRUMENTATIONKEY with the Application Insights instrumentation key.

Cevap

Register the telemetry worker service in the Program.cs file and configure the APPLICATIONINSIGHTS_CONNECTION_STRING environment variable.
For C# Worker Services, the Application Insights SDK is registered using the AddApplicationInsightsTelemetryWorkerService method. Telemetry routing is configured using the connection string, which is automatically read from the APPLICATIONINSIGHTS_CONNECTION_STRING environment variable by the SDK.

Adım Adım Çözüm

1
Select the correct SDK registration method for non-web workloads.
Use the AddApplicationInsightsTelemetryWorkerService method in the services container.
Worker Services do not have HTTP contexts and require the specialized worker service registration rather than the standard web registration.
2
Configure the telemetry endpoint credentials.
Define the APPLICATIONINSIGHTS_CONNECTION_STRING environment variable with the resource's connection string.
Using connection strings is the modern, non-deprecated standard for routing telemetry data to the correct Application Insights instance.

Anahtar Kavram

Configuring SDK-based telemetry in non-web .NET applications using connection strings
Tahmini Süre:2m 0s
Bu soruyu puanla