Skip to content

Commit 78d05a3

Browse files
Merge pull request #232190 from alexwolfmsft/geolocation-version-update
updated .net versions
2 parents b74ecc8 + 14b33b8 commit 78d05a3

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

articles/azure-monitor/app/ip-collection.md

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,7 @@ Content-Length: 54
128128
129129
## Telemetry initializer
130130
131-
If you need a more flexible alternative than `DisableIpMasking`, you can use a [telemetry initializer](./api-filtering-sampling.md#addmodify-properties-itelemetryinitializer) to copy all or part of the IP address to a custom field.
132-
133-
# [.NET](#tab/net)
134-
135-
### ASP.NET or ASP.NET Core
131+
If you need a more flexible alternative than `DisableIpMasking`, you can use a [telemetry initializer](./api-filtering-sampling.md#addmodify-properties-itelemetryinitializer) to copy all or part of the IP address to a custom field. The code for this class is the same across .NET versions.
136132
137133
```csharp
138134
using Microsoft.ApplicationInsights.Channel;
@@ -160,11 +156,32 @@ namespace MyWebApp
160156
> [!NOTE]
161157
> If you can't access `ISupportProperties`, make sure you're running the latest stable release of the Application Insights SDK. `ISupportProperties` is intended for high cardinality values. `GlobalProperties` is more appropriate for low cardinality values like region name and environment name.
162158
163-
### Enable the telemetry initializer for ASP.NET
159+
160+
# [.NET 6.0+](#tab/framework)
164161

165162
```csharp
166-
using Microsoft.ApplicationInsights.Extensibility;
163+
using Microsoft.ApplicationInsights.Extensibility;
164+
using CustomInitializer.Telemetry;
165+
166+
builder.services.AddSingleton<ITelemetryInitializer, CloneIPAddress>();
167+
```
167168

169+
# [.NET 5.0](#tab/dotnet5)
170+
171+
```csharp
172+
using Microsoft.ApplicationInsights.Extensibility;
173+
using CustomInitializer.Telemetry;
174+
175+
public void ConfigureServices(IServiceCollection services)
176+
{
177+
services.AddSingleton<ITelemetryInitializer, CloneIPAddress>();
178+
}
179+
```
180+
181+
# [ASP.NET Framework](#tab/dotnet6)
182+
183+
```csharp
184+
using Microsoft.ApplicationInsights.Extensibility;
168185

169186
namespace MyWebApp
170187
{
@@ -180,18 +197,7 @@ namespace MyWebApp
180197

181198
```
182199

183-
### Enable the telemetry initializer for ASP.NET Core
184-
185-
You can create your telemetry initializer the same way for ASP.NET Core as for ASP.NET. To enable the initializer, use the following example for reference:
186-
187-
```csharp
188-
using Microsoft.ApplicationInsights.Extensibility;
189-
using CustomInitializer.Telemetry;
190-
public void ConfigureServices(IServiceCollection services)
191-
{
192-
services.AddSingleton<ITelemetryInitializer, CloneIPAddress>();
193-
}
194-
```
200+
---
195201

196202
# [Node.js](#tab/nodejs)
197203

0 commit comments

Comments
 (0)