Skip to content

Commit bcc3253

Browse files
(AzureCXP) MicrosoftDocs/azure-docs#106410
1 parent eb6e4d0 commit bcc3253

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

articles/azure-monitor/app/worker-service.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ The full example is shared at this [GitHub page](https://github.com/microsoft/Ap
232232
```csharp
233233
using Microsoft.ApplicationInsights;
234234
using Microsoft.ApplicationInsights.DataContracts;
235+
using Microsoft.ApplicationInsights.WorkerService;
235236
using Microsoft.Extensions.DependencyInjection;
236237
using Microsoft.Extensions.Logging;
237238
using System;
@@ -250,7 +251,7 @@ The full example is shared at this [GitHub page](https://github.com/microsoft/Ap
250251
// Being a regular console app, there is no appsettings.json or configuration providers enabled by default.
251252
// Hence instrumentation key/ connection string and any changes to default logging level must be specified here.
252253
services.AddLogging(loggingBuilder => loggingBuilder.AddFilter<Microsoft.Extensions.Logging.ApplicationInsights.ApplicationInsightsLoggerProvider>("Category", LogLevel.Information));
253-
services.AddApplicationInsightsTelemetryWorkerService("instrumentation key here");
254+
services.AddApplicationInsightsTelemetryWorkerService((ApplicationInsightsServiceOptions options) => options.ConnectionString = "InstrumentationKey=<instrumentation key here>");
254255

255256
// To pass a connection string
256257
// - aiserviceoptions must be created

0 commit comments

Comments
 (0)