Question

Difficulty: Very hardConfigure Application Insights Instrumentation and Telemetry

You are configuring telemetry for an ASP.NET Core web application deployed to Azure Container Apps using the .NET SDK. In your `Program.cs` file, you register the Application Insights services using the following code:

csharp
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddApplicationInsightsTelemetry();

You configure the Container App with an environment variable named `APPINSIGHTS_INSTRUMENTATIONKEY` containing the valid instrumentation key of your Application Insights resource.

After deploying the application, you observe that no telemetry data is being received by Application Insights. There are no exception messages in the application logs, and the application is running successfully.

Which of the following modifications is required to resolve this issue and enable telemetry collection?

  1. Configure the APPLICATIONINSIGHTS_CONNECTION_STRING environment variable in the Azure Container App instead of APPINSIGHTS_INSTRUMENTATIONKEY.Answer
  2. B
    Add a Key Vault access policy to grant the Container App's system-assigned managed identity permissions to access the Application Insights resource.
  3. C
    Modify the App Configuration reference to use the @Microsoft.KeyVault prefix to resolve the instrumentation key dynamically.
  4. D
    Adjust the container's autoscale rule metrics to resolve metric conflicts, which are currently blocking outbound telemetry traffic.

Answer

Configure the APPLICATIONINSIGHTS_CONNECTION_STRING environment variable in the Azure Container App instead of APPINSIGHTS_INSTRUMENTATIONKEY.
The correct option correctly identifies that the modern Application Insights .NET SDK requires the connection string configured via the `APPLICATIONINSIGHTS_CONNECTION_STRING` environment variable. Ingestion using only the instrumentation key (`APPINSIGHTS_INSTRUMENTATIONKEY` or the `InstrumentationKey` property in code) has been deprecated and does not work for telemetry ingestion in modern SDK releases.

Step-by-Step Solution

1
Identify the environment variable being used to configure Application Insights.
The application is currently configured with the deprecated `APPINSIGHTS_INSTRUMENTATIONKEY` environment variable.
To determine if the configuration uses the obsolete instrumentation key or the required connection string.
2
Analyze SDK requirements for telemetry ingestion.
The modern Application Insights SDK requires a connection string (`APPLICATIONINSIGHTS_CONNECTION_STRING`) to successfully route and ingest telemetry.
Ingestion using only the instrumentation key has been deprecated and is ignored by the SDK, resulting in a silent failure where no telemetry is sent.
3
Apply the correct environment variable configuration.
Replace `APPINSIGHTS_INSTRUMENTATIONKEY` with `APPLICATIONINSIGHTS_CONNECTION_STRING` containing the full connection string from the Azure Portal.
This supplies the required endpoint information and key to the SDK, enabling telemetry to flow successfully.

Key Concept

Application Insights SDK requires the use of Connection Strings rather than the deprecated Instrumentation Key to ingest telemetry data.
Rate this question