Skip to content

Commit 82c8e25

Browse files
committed
update to add worker config too
Signed-off-by: Hannah Hunter <[email protected]>
1 parent a2a0a5c commit 82c8e25

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

articles/azure-monitor/profiler/profiler-aspnetcore-linux.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ In this guide, you'll:
4141
dotnet add package Microsoft.ApplicationInsights.Profiler.AspNetCore
4242
```
4343

44-
1. In your preferred code editor, enable Application Insights and Profiler in `Program.cs`:
44+
1. In your preferred code editor, enable Application Insights and Profiler in `Program.cs` for `WebAPI`:
4545

4646
```csharp
4747
// Add services to the container.
@@ -51,6 +51,26 @@ In this guide, you'll:
5151
profilerSettings.Duration = TimeSpan.FromMinutes(1);
5252
});
5353
```
54+
55+
You can also enable Application Insights and Profiler for `Worker`. Update the `Program.cs` file for the `Worker` with the following:
56+
57+
```csharp
58+
using ServiceProfilerInWorkerNet6;
59+
60+
IHost host = Host.CreateDefaultBuilder(args)
61+
.ConfigureServices(services =>
62+
{
63+
services.AddApplicationInsightsTelemetryWorkerService();
64+
services.AddServiceProfiler();
65+
66+
services.AddHostedService<Worker>();
67+
})
68+
.Build();
69+
70+
await host.RunAsync();
71+
```
72+
73+
5474
1. Save and commit your changes to the local repository:
5575

5676
```console

0 commit comments

Comments
 (0)