You are developing a C# .NET 8 worker service hosted on Azure Container Apps. The service processes queue messages and is configured to send telemetry to Application Insights.
In Program.cs, you register the telemetry services:
csharp
var builder = Host.CreateApplicationBuilder(args);
builder.Services.AddApplicationInsightsTelemetryWorkerService(options =>
{
options.ConnectionString = builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"];
});
Within a separate processor class, you instantiate the telemetry client manually to log custom events:
csharp
public class QueueProcessor
{
private static readonly TelemetryClient telemetryClient = new TelemetryClient();
public void ProcessMessage(string message)
{
// Processing logic
telemetryClient.TrackEvent("MessageProcessed");
}
}
During testing, you observe that standard system metrics and dependency telemetry are successfully recorded in Application Insights, but the custom MessageProcessed events are missing.
Which of the following describes the root cause of this behavior?
- AThe environment variable APPLICATIONINSIGHTS_CONNECTION_STRING is missing or not set in the Azure Container App environment settings.
- BThe managed identity for the Azure Container App has not been configured with a Key Vault access policy allowing GET secret permissions.
- The static TelemetryClient is initialized using its parameterless constructor, which does not resolve the configured TelemetryConfiguration from the dependency injection container.Answer
- DThe connection string defined in the App Configuration store contains an invalid Key Vault reference syntax, preventing configuration resolution.