You are developing a .NET 8 console application that will run as a WebJob on a Linux Azure App Service. The application must track custom operational metrics by using the Application Insights SDK.
You write the following code to initialize the telemetry tracking:
csharp
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.Extensibility;
class Program
{
static void Main(string[] args)
{
var config = TelemetryConfiguration.CreateDefault();
var client = new TelemetryClient(config);
client.TrackEvent("WebJobStarted");
client.Flush();
}
}
When you run the WebJob, the application executes without throwing any exceptions, but no custom events are visible in your Application Insights resource.
Which of the following changes must you make to ensure that the telemetry data is sent successfully to Azure Monitor?
- AInstantiate the TelemetryConfiguration using the default constructor and assign your Application Insights instrumentation key to the InstrumentationKey property.
- Set the ConnectionString property of the TelemetryConfiguration instance to your Application Insights connection string before instantiating the TelemetryClient.Answer
- CConfigure a Key Vault access policy that grants the App Service's system-assigned managed identity GET permissions for the Application Insights secret.
- DDefine an environment variable on the App Service with the Key Vault reference syntax without the secret URI to automatically bind the connection string.