You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. Enable Application Insights and Profiler in `Startup.cs`:
71
+
5. Enable Application Insights and Profiler
72
+
73
+
### [ASP.NET Core 6 and later](#tab/net-core-new)
74
+
75
+
Add `builder.Services.AddApplicationInsightsTelemetry()` and `builder.Services.AddServiceProfiler()` after the `WebApplication.CreateBuilder()` method in `Program.cs`:
76
+
77
+
```csharp
78
+
var builder = WebApplication.CreateBuilder(args);
79
+
80
+
builder.Services.AddApplicationInsightsTelemetry(); // Add this line of code to enable Application Insights.
81
+
builder.Services.AddServiceProfiler(); // Add this line of code to enable Profiler
82
+
builder.Services.AddControllersWithViews();
83
+
84
+
var app = builder.Build();
85
+
```
86
+
87
+
### [ASP.NET Core 5 and earlier](#tab/net-core-old)
88
+
89
+
Add `services.AddApplicationInsightsTelemetry()` and `services.AddServiceProfiler()` to the `ConfigureServices()` method in `Startup.cs`:
72
90
73
-
```csharp
74
-
public void ConfigureServices(IServiceCollection services)
75
-
{
76
-
services.AddApplicationInsightsTelemetry(); // Add this line of code to enable Application Insights.
77
-
services.AddServiceProfiler(); // Add this line of code to Enable Profiler
78
-
services.AddControllersWithViews();
79
-
}
80
-
```
91
+
```csharp
92
+
public void ConfigureServices(IServiceCollection services)
93
+
{
94
+
services.AddApplicationInsightsTelemetry(); // Add this line of code to enable Application Insights.
95
+
services.AddServiceProfiler(); // Add this line of code to enable Profiler
96
+
services.AddControllersWithViews();
97
+
}
98
+
```
81
99
82
100
## Pull the latest ASP.NET Core build/runtime images
83
101
@@ -87,7 +105,7 @@ In this article, you'll learn the various ways you can:
87
105
cd examples/EnableServiceProfilerForContainerAppNet6
88
106
```
89
107
90
-
1. Pull the latest ASP.NET Core images
108
+
2. Pull the latest ASP.NET Core images
91
109
92
110
```shell
93
111
docker pull mcr.microsoft.com/dotnet/sdk:6.0
@@ -103,7 +121,7 @@ In this article, you'll learn the various ways you can:
103
121
104
122
:::image type="content" source="./media/profiler-containerinstances/application-insights-key.png" alt-text="Screenshot of finding instrumentation key in Azure portal.":::
105
123
106
-
1. Open `appsettings.json` and add your Application Insights instrumentation key to this code section:
124
+
2. Open `appsettings.json` and add your Application Insights instrumentation key to this code section:
107
125
108
126
```json
109
127
{
@@ -118,13 +136,13 @@ In this article, you'll learn the various ways you can:
118
136
119
137
1. Review the `Dockerfile`.
120
138
121
-
1. Build the example image:
139
+
2. Build the example image:
122
140
123
141
```bash
124
142
docker build -t profilerapp .
125
143
```
126
144
127
-
1. Run the container:
145
+
3. Run the container:
128
146
129
147
```bash
130
148
docker run -d -p 8080:80 --name testapp profilerapp
@@ -162,8 +180,8 @@ Service Profiler session finished. # A profiling session is complet
162
180
## View the Service Profiler traces
163
181
164
182
1. Wait for 2-5 minutes so the events can be aggregated to Application Insights.
165
-
1. Open the **Performance** blade in your Application Insights resource.
166
-
1. Once the trace process is complete, you'll see the Profiler Traces button like it below:
183
+
2. Open the **Performance** blade in your Application Insights resource.
184
+
3. Once the trace process is complete, you'll see the Profiler Traces button like it below:
167
185
168
186
:::image type="content" source="./media/profiler-containerinstances/profiler-traces.png" alt-text="Screenshot of Profile traces in the performance blade.":::
0 commit comments