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.)
- Call builder.Services.AddApplicationInsightsTelemetryWorkerService(); in the Program.cs file.Answer
- Configure an environment variable named APPLICATIONINSIGHTS_CONNECTION_STRING with the Application Insights connection string.Answer
- CCall builder.Services.AddApplicationInsightsTelemetry(); in the Program.cs file.
- DConfigure an environment variable named APPINSIGHTS_INSTRUMENTATIONKEY with the Application Insights instrumentation key.
Answer
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.
Step-by-Step Solution
Key Concept
Configuring SDK-based telemetry in non-web .NET applications using connection strings
Estimated Time:2m 0s