You are developing a C# .NET 8 Azure Function in an isolated worker process. You configure custom telemetry tracking in the function app using Dependency Injection in the `Program.cs` file. However, during runtime, you find that custom telemetry generated via `TelemetryClient` is not being sent to Azure Monitor because the connection string is missing or not bound correctly in the SDK setup.
You have the following code in your `Program.cs` file:
csharp
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults()
.ConfigureServices((context, services) =>
{
services.AddApplicationInsightsTelemetryWorkerService(options =>
{
// Line X
});
})
.Build();
await host.RunAsync();
Which of the following lines of code should you insert at `Line X` to correctly bind the connection string from configuration?
- options.ConnectionString = context.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"];Cevap
- Boptions.InstrumentationKey = context.Configuration["APPINSIGHTS_INSTRUMENTATIONKEY"];
- Coptions.InstrumentationKey = context.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"];
- DTelemetryConfiguration.Active.ConnectionString = context.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"];