@azure/mcp-linux-arm64 2.0.0-beta.9 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/NOTICE.txt +5683 -4849
  2. package/README.md +148 -27
  3. package/dist/Azure.Mcp.Tools.AzureMigrate.xml +1060 -0
  4. package/dist/Instrumentation/Resources/api-reference/dotnet/ActivityProcessors.md +119 -0
  5. package/dist/Instrumentation/Resources/api-reference/dotnet/AddApplicationInsightsTelemetry.md +129 -0
  6. package/dist/Instrumentation/Resources/api-reference/dotnet/AddApplicationInsightsTelemetryWorkerService.md +115 -0
  7. package/dist/Instrumentation/Resources/api-reference/dotnet/AddOpenTelemetry.md +153 -0
  8. package/dist/Instrumentation/Resources/api-reference/dotnet/ApplicationInsightsWeb.md +103 -0
  9. package/dist/Instrumentation/Resources/api-reference/dotnet/AzureMonitorExporter.md +137 -0
  10. package/dist/Instrumentation/Resources/api-reference/dotnet/ConfigureOpenTelemetryProvider.md +218 -0
  11. package/dist/Instrumentation/Resources/api-reference/dotnet/ConfigureResource.md +119 -0
  12. package/dist/Instrumentation/Resources/api-reference/dotnet/ConsoleExporter.md +47 -0
  13. package/dist/Instrumentation/Resources/api-reference/dotnet/EntityFrameworkInstrumentation.md +56 -0
  14. package/dist/Instrumentation/Resources/api-reference/dotnet/HttpInstrumentation.md +109 -0
  15. package/dist/Instrumentation/Resources/api-reference/dotnet/LogProcessors.md +101 -0
  16. package/dist/Instrumentation/Resources/api-reference/dotnet/OpenTelemetrySdkCreate.md +146 -0
  17. package/dist/Instrumentation/Resources/api-reference/dotnet/OtlpExporter.md +88 -0
  18. package/dist/Instrumentation/Resources/api-reference/dotnet/RedisInstrumentation.md +63 -0
  19. package/dist/Instrumentation/Resources/api-reference/dotnet/Sampling.md +86 -0
  20. package/dist/Instrumentation/Resources/api-reference/dotnet/SdkCreateTracerProviderBuilder.md +127 -0
  21. package/dist/Instrumentation/Resources/api-reference/dotnet/SqlClientInstrumentation.md +53 -0
  22. package/dist/Instrumentation/Resources/api-reference/dotnet/TelemetryClient.md +122 -0
  23. package/dist/Instrumentation/Resources/api-reference/dotnet/TelemetryConfigurationBuilder.md +173 -0
  24. package/dist/Instrumentation/Resources/api-reference/dotnet/UseAzureMonitor.md +96 -0
  25. package/dist/Instrumentation/Resources/api-reference/dotnet/UseAzureMonitorExporter.md +146 -0
  26. package/dist/Instrumentation/Resources/api-reference/dotnet/WithLogging.md +109 -0
  27. package/dist/Instrumentation/Resources/api-reference/dotnet/WithMetrics.md +105 -0
  28. package/dist/Instrumentation/Resources/api-reference/dotnet/WithTracing.md +91 -0
  29. package/dist/Instrumentation/Resources/concepts/dotnet/appinsights-aspnetcore.md +113 -0
  30. package/dist/Instrumentation/Resources/concepts/dotnet/aspnet-classic-appinsights.md +95 -0
  31. package/dist/Instrumentation/Resources/concepts/dotnet/azure-monitor-distro.md +102 -0
  32. package/dist/Instrumentation/Resources/concepts/dotnet/opentelemetry-pipeline.md +57 -0
  33. package/dist/Instrumentation/Resources/concepts/nodejs/azure-monitor-overview.md +106 -0
  34. package/dist/Instrumentation/Resources/concepts/nodejs/opentelemetry-pipeline.md +201 -0
  35. package/dist/Instrumentation/Resources/concepts/python/azure-monitor-overview.md +122 -0
  36. package/dist/Instrumentation/Resources/concepts/python/opentelemetry-pipeline.md +154 -0
  37. package/dist/Instrumentation/Resources/examples/dotnet/aspnet-classic-setup.md +80 -0
  38. package/dist/Instrumentation/Resources/examples/dotnet/aspnetcore-distro-setup.md +156 -0
  39. package/dist/Instrumentation/Resources/examples/dotnet/aspnetcore-setup.md +160 -0
  40. package/dist/Instrumentation/Resources/examples/dotnet/workerservice-setup.md +154 -0
  41. package/dist/Instrumentation/Resources/examples/nodejs/bunyan-setup.md +301 -0
  42. package/dist/Instrumentation/Resources/examples/nodejs/console-setup.md +284 -0
  43. package/dist/Instrumentation/Resources/examples/nodejs/express-setup.md +169 -0
  44. package/dist/Instrumentation/Resources/examples/nodejs/fastify-setup.md +237 -0
  45. package/dist/Instrumentation/Resources/examples/nodejs/langchain-js-setup.md +310 -0
  46. package/dist/Instrumentation/Resources/examples/nodejs/mongodb-setup.md +185 -0
  47. package/dist/Instrumentation/Resources/examples/nodejs/mysql-setup.md +231 -0
  48. package/dist/Instrumentation/Resources/examples/nodejs/nestjs-setup.md +184 -0
  49. package/dist/Instrumentation/Resources/examples/nodejs/nextjs-setup.md +320 -0
  50. package/dist/Instrumentation/Resources/examples/nodejs/postgres-setup.md +147 -0
  51. package/dist/Instrumentation/Resources/examples/nodejs/redis-setup.md +198 -0
  52. package/dist/Instrumentation/Resources/examples/nodejs/winston-setup.md +260 -0
  53. package/dist/Instrumentation/Resources/examples/python/console-setup.md +392 -0
  54. package/dist/Instrumentation/Resources/examples/python/django-setup.md +269 -0
  55. package/dist/Instrumentation/Resources/examples/python/fastapi-setup.md +256 -0
  56. package/dist/Instrumentation/Resources/examples/python/flask-setup.md +218 -0
  57. package/dist/Instrumentation/Resources/examples/python/genai-setup.md +214 -0
  58. package/dist/Instrumentation/Resources/examples/python/generic-setup.md +164 -0
  59. package/dist/Instrumentation/Resources/migration/dotnet/aad-authentication-migration.md +150 -0
  60. package/dist/Instrumentation/Resources/migration/dotnet/appinsights-2x-to-3x-code-migration.md +164 -0
  61. package/dist/Instrumentation/Resources/migration/dotnet/appinsights-2x-to-3x-no-code-change.md +92 -0
  62. package/dist/Instrumentation/Resources/migration/dotnet/aspnet-classic-2x-to-3x-code-migration.md +190 -0
  63. package/dist/Instrumentation/Resources/migration/dotnet/console-2x-to-3x-code-migration.md +106 -0
  64. package/dist/Instrumentation/Resources/migration/dotnet/ilogger-migration.md +54 -0
  65. package/dist/Instrumentation/Resources/migration/dotnet/workerservice-2x-to-3x-code-migration.md +126 -0
  66. package/dist/Instrumentation/Resources/migration/dotnet/workerservice-2x-to-3x-no-code-change.md +102 -0
  67. package/dist/azmcp +0 -0
  68. package/package.json +1 -1
@@ -0,0 +1,150 @@
1
+ ---
2
+ title: AAD Authentication Migration (2.x to 3.x)
3
+ category: migration
4
+ applies-to: 3.x
5
+ ---
6
+
7
+ # AAD Authentication Migration (2.x → 3.x)
8
+
9
+ ## What changed
10
+
11
+ In 2.x, `SetAzureTokenCredential(object)` existed on `TelemetryConfiguration` but accepted an `object` parameter — it used reflection internally to avoid a hard dependency on `Azure.Core`. Some teams also used `IConfigureOptions<TelemetryConfiguration>` workarounds to configure credentials in DI scenarios.
12
+
13
+ In 3.x, the method signature changed to **strongly typed** and new DI-friendly options were added:
14
+ - `TelemetryConfiguration.SetAzureTokenCredential(TokenCredential)` — **Signature changed** from `object` to `TokenCredential`. Must be called before a `TelemetryClient` is created from that configuration.
15
+ - `ApplicationInsightsServiceOptions.Credential` — **New in 3.x**. Preferred for DI scenarios (ASP.NET Core / Worker Service). Set your `TokenCredential` directly in the options lambda.
16
+
17
+ Other key changes:
18
+ - `TelemetryConfiguration.Active` — **Removed**. Use `TelemetryConfiguration.CreateDefault()` instead. Note: `CreateDefault()` now returns an internal static configuration (singleton-like) rather than a new instance each time.
19
+
20
+ ---
21
+
22
+ ## DI Scenario (ASP.NET Core / Worker Service)
23
+
24
+ In 2.x, AAD auth in DI apps was commonly configured via `IConfigureOptions<TelemetryConfiguration>` workarounds. In 3.x, use the new `Credential` property on `ApplicationInsightsServiceOptions` directly — simpler and no extra class needed.
25
+
26
+ ### Before (2.x — IConfigureOptions pattern)
27
+
28
+ ```csharp
29
+ using Microsoft.ApplicationInsights.Extensibility;
30
+ using Microsoft.Extensions.Options;
31
+ using Azure.Identity;
32
+
33
+ public class TelemetryConfigurationEnricher : IConfigureOptions<TelemetryConfiguration>
34
+ {
35
+ public void Configure(TelemetryConfiguration options)
36
+ {
37
+ // 2.x signature: SetAzureTokenCredential(object) — accepts object, uses reflection
38
+ object credential = new DefaultAzureCredential();
39
+ options.SetAzureTokenCredential(credential);
40
+ }
41
+ }
42
+
43
+ // In Startup.cs / Program.cs:
44
+ services.AddSingleton<IConfigureOptions<TelemetryConfiguration>, TelemetryConfigurationEnricher>();
45
+ services.AddApplicationInsightsTelemetry();
46
+ ```
47
+
48
+ ### After (3.x — Credential property on options)
49
+
50
+ ```csharp
51
+ using Microsoft.Extensions.DependencyInjection;
52
+ using Microsoft.ApplicationInsights.AspNetCore.Extensions;
53
+ using Azure.Identity;
54
+
55
+ builder.Services.AddApplicationInsightsTelemetry(options =>
56
+ {
57
+ options.ConnectionString = "InstrumentationKey=...;IngestionEndpoint=...";
58
+ options.Credential = new DefaultAzureCredential();
59
+ });
60
+ ```
61
+
62
+ ### Migration steps (DI)
63
+
64
+ 1. **Remove the `IConfigureOptions<TelemetryConfiguration>` class** that calls `SetAzureTokenCredential()` (e.g., `TelemetryConfigurationEnricher`). Delete the entire class file if it only handled AAD auth.
65
+
66
+ 2. **Remove the DI registration** for the configurator:
67
+ ```csharp
68
+ // Delete this line:
69
+ services.AddSingleton<IConfigureOptions<TelemetryConfiguration>, TelemetryConfigurationEnricher>();
70
+ ```
71
+
72
+ 3. **Set the `Credential` property** in your `AddApplicationInsightsTelemetry()` options:
73
+ ```csharp
74
+ builder.Services.AddApplicationInsightsTelemetry(options =>
75
+ {
76
+ options.Credential = new DefaultAzureCredential();
77
+ });
78
+ ```
79
+
80
+ 4. For **Worker Service** apps, the same applies to `AddApplicationInsightsTelemetryWorkerService()`:
81
+ ```csharp
82
+ services.AddApplicationInsightsTelemetryWorkerService(options =>
83
+ {
84
+ options.Credential = new DefaultAzureCredential();
85
+ });
86
+ ```
87
+
88
+ ---
89
+
90
+ ## Non-DI Scenario (Console apps, manual TelemetryConfiguration)
91
+
92
+ For apps that create `TelemetryConfiguration` directly (console apps, batch jobs, etc.), the new `SetAzureTokenCredential` method provides built-in AAD support. The main breaking change is that `TelemetryConfiguration.Active` is removed.
93
+
94
+ ### Before (2.x — TelemetryConfiguration.Active)
95
+
96
+ ```csharp
97
+ using Microsoft.ApplicationInsights;
98
+ using Microsoft.ApplicationInsights.Extensibility;
99
+ using Azure.Identity;
100
+
101
+ var config = TelemetryConfiguration.Active;
102
+ config.ConnectionString = "InstrumentationKey=...;IngestionEndpoint=...";
103
+ // 2.x signature: SetAzureTokenCredential(object) — accepts object, uses reflection
104
+ config.SetAzureTokenCredential((object)new DefaultAzureCredential());
105
+
106
+ var client = new TelemetryClient(config);
107
+ ```
108
+
109
+ ### After (3.x — CreateDefault)
110
+
111
+ ```csharp
112
+ using Microsoft.ApplicationInsights;
113
+ using Microsoft.ApplicationInsights.Extensibility;
114
+ using Azure.Identity;
115
+
116
+ var config = TelemetryConfiguration.CreateDefault();
117
+ config.ConnectionString = "InstrumentationKey=...;IngestionEndpoint=...";
118
+ // 3.x signature: SetAzureTokenCredential(TokenCredential) — strongly typed
119
+ config.SetAzureTokenCredential(new DefaultAzureCredential());
120
+
121
+ var client = new TelemetryClient(config);
122
+ ```
123
+
124
+ ### Migration steps (non-DI)
125
+
126
+ 1. **Replace `TelemetryConfiguration.Active`** with `TelemetryConfiguration.CreateDefault()` — the `Active` static property is removed in 3.x. Note that `CreateDefault()` returns an internal static configuration (singleton-like) rather than creating a new instance.
127
+
128
+ 2. **Use `SetAzureTokenCredential(TokenCredential)`** — the parameter type changed from `object` (2.x) to strongly typed `TokenCredential` (3.x). If your code previously cast to `object`, remove the cast. Call it **before** creating a `TelemetryClient` from that configuration.
129
+
130
+ 3. If using a custom `TokenCredential` (e.g., `ManagedIdentityCredential` with a specific client ID), pass it directly:
131
+ ```csharp
132
+ var credential = new ManagedIdentityCredential("your-client-id");
133
+ var config = TelemetryConfiguration.CreateDefault();
134
+ config.SetAzureTokenCredential(credential);
135
+ var client = new TelemetryClient(config);
136
+ ```
137
+
138
+ ---
139
+
140
+ ## Notes
141
+
142
+ - The `Azure.Identity` package is still required — no change there.
143
+ - If you previously used `SetAzureTokenCredential` conditionally (e.g., only in certain environments), apply the same condition when setting `options.Credential` (DI) or calling `SetAzureTokenCredential` (non-DI).
144
+ - Both paths ultimately set `AzureMonitorExporterOptions.Credential` under the hood.
145
+
146
+ ## See also
147
+
148
+ - [AddApplicationInsightsTelemetry API reference](learn://api-reference/dotnet/AddApplicationInsightsTelemetry.md) — full list of `ApplicationInsightsServiceOptions` properties
149
+ - [UseAzureMonitor API reference](learn://api-reference/dotnet/UseAzureMonitor.md) — if migrating to Azure Monitor OpenTelemetry Distro instead
150
+ - [App Insights 2.x → 3.x code migration](learn://migration/dotnet/appinsights-2x-to-3x-code-migration.md) — full migration guide
@@ -0,0 +1,164 @@
1
+ ---
2
+ title: Application Insights 2.x to 3.x Migration
3
+ category: migration
4
+ applies-to: 3.x
5
+ ---
6
+
7
+ # App Insights 2.x → 3.x Code Migration
8
+
9
+ ## What changed
10
+
11
+ 3.x uses OpenTelemetry under the hood. The main entry point is the same — `AddApplicationInsightsTelemetry()` — but several options and extension methods were removed.
12
+
13
+ Key changes:
14
+ - `InstrumentationKey` → use `ConnectionString`
15
+ - `EnableAdaptiveSampling` → use `TracesPerSecond` (default `5`) or `SamplingRatio`
16
+ - Logging is automatic — `ApplicationInsightsLoggerProvider` was removed
17
+ - New: `Credential` for AAD authentication, `EnableTraceBasedLogsSampler` for log sampling control
18
+
19
+ ## Before / after
20
+
21
+ **2.x**
22
+ ```csharp
23
+ using Microsoft.Extensions.DependencyInjection;
24
+
25
+ builder.Services.AddApplicationInsightsTelemetry(options =>
26
+ {
27
+ options.InstrumentationKey = "your-ikey"; // Removed in 3.x
28
+ options.EnableAdaptiveSampling = false; // Removed in 3.x
29
+ options.DeveloperMode = true; // Removed in 3.x
30
+ });
31
+ ```
32
+
33
+ **3.x**
34
+ ```csharp
35
+ using Microsoft.Extensions.DependencyInjection;
36
+ using Microsoft.ApplicationInsights.AspNetCore.Extensions;
37
+
38
+ builder.Services.AddApplicationInsightsTelemetry(options =>
39
+ {
40
+ options.ConnectionString = "InstrumentationKey=...;IngestionEndpoint=...";
41
+ options.SamplingRatio = 1.0f; // No sampling (collect everything)
42
+ // DeveloperMode — no replacement needed, remove the line
43
+ });
44
+ ```
45
+
46
+ Or set `APPLICATIONINSIGHTS_CONNECTION_STRING` as an environment variable and call `AddApplicationInsightsTelemetry()` with no arguments.
47
+
48
+ ## Property changes
49
+
50
+ | Property | Status | Action required |
51
+ |---|---|---|
52
+ | `ConnectionString` | Unchanged | None. |
53
+ | `ApplicationVersion` | Unchanged | None. |
54
+ | `EnableQuickPulseMetricStream` | Unchanged | None. Default `true`. |
55
+ | `EnablePerformanceCounterCollectionModule` | Unchanged | None. Default `true`. |
56
+ | `EnableDependencyTrackingTelemetryModule` | Unchanged | None. Default `true`. |
57
+ | `EnableRequestTrackingTelemetryModule` | Unchanged | None. Default `true`. |
58
+ | `AddAutoCollectedMetricExtractor` | Unchanged | None. Default `true`. |
59
+ | `EnableAuthenticationTrackingJavaScript` | Unchanged | None. Default `false`. |
60
+ | `InstrumentationKey` | **Removed** | Use `ConnectionString`. |
61
+ | `EnableAdaptiveSampling` | **Removed** | Use `TracesPerSecond` or `SamplingRatio`. |
62
+ | `DeveloperMode` | **Removed** | Delete the line. |
63
+ | `EndpointAddress` | **Removed** | Endpoint is now part of `ConnectionString`. |
64
+ | `EnableHeartbeat` | **Removed** | Delete the line; heartbeat is automatic. |
65
+ | `EnableDebugLogger` | **Removed** | Delete the line. |
66
+ | `RequestCollectionOptions` | **Removed** | Delete the line. |
67
+ | `DependencyCollectionOptions` | **Removed** | Delete the line. |
68
+ | `TelemetryInitializers` | **Removed** | Delete the line. |
69
+ | `Credential` | **New** | `TokenCredential`, default `null`. Set for AAD auth. |
70
+ | `TracesPerSecond` | **New** | `double?`, effective default `5`. Rate-limited sampling. |
71
+ | `SamplingRatio` | **New** | `float?`, default `null`. Fixed-rate sampling (0.0–1.0). |
72
+ | `EnableTraceBasedLogsSampler` | **New** | `bool?`, effective default `true`. Logs follow parent trace sampling. |
73
+
74
+ ## Removed extension methods
75
+
76
+ | Method | Replacement |
77
+ |---|---|
78
+ | `AddApplicationInsightsTelemetry(string instrumentationKey)` | Use parameterless overload + `ConnectionString` in options or env var. |
79
+ | `UseApplicationInsights()` (all `IWebHostBuilder` overloads) | Use `AddApplicationInsightsTelemetry()` on `IServiceCollection`. |
80
+ | `AddApplicationInsightsTelemetryProcessor<T>()` | Use OpenTelemetry processors. |
81
+ | `ConfigureTelemetryModule<T>()` | Removed; module functionality is built-in. |
82
+
83
+ ## Removed interfaces and classes
84
+
85
+ | Type | Notes |
86
+ |---|---|
87
+ | `ITelemetryInitializer` | Removed. Convert to `BaseProcessor<Activity>` with `OnStart`. Register via `.AddProcessor<T>()` in the OpenTelemetry pipeline. |
88
+ | `ITelemetryProcessor` | Removed. Convert to `BaseProcessor<Activity>` with `OnEnd`. To drop telemetry, clear `data.ActivityTraceFlags &= ~ActivityTraceFlags.Recorded`. Register via `.AddProcessor<T>()`. |
89
+ | `ApplicationInsightsLoggerProvider` | Logging is now automatic. No replacement needed. |
90
+ | `ExceptionTrackingMiddleware` | Exception tracking is built-in. |
91
+
92
+ ## TelemetryClient changes
93
+
94
+ | Change | Details |
95
+ |---|---|
96
+ | `TrackEvent` | 3-param overload `(string, IDictionary<string,string>, IDictionary<string,double>)` **removed** — metrics dict dropped. Use 2-param overload and track metrics separately via `TrackMetric()`. |
97
+ | `TrackException` | 3-param overload with `IDictionary<string,double>` **removed**. Use 2-param overload and track metrics separately via `TrackMetric()`. |
98
+ | `TrackAvailability` | 8-param overload with trailing `IDictionary<string,double>` **removed**. Use 7-param overload and track metrics separately via `TrackMetric()`. |
99
+ | `TrackPageView` | **Removed entirely** (both overloads). Use `TrackEvent` or `TrackRequest` instead. |
100
+ | `GetMetric` | `MetricConfiguration` and `MetricAggregationScope` params **removed** from all overloads. Use simplified `GetMetric(metricId, ...)`. |
101
+ | parameterless `TelemetryClient()` | **Removed**. Use `TelemetryClient(TelemetryConfiguration)` via DI. |
102
+ | `client.InstrumentationKey` | **Removed**. Use `TelemetryConfiguration.ConnectionString`. |
103
+ | `TrackTrace`, `TrackMetric`, `TrackRequest`, `TrackDependency` (full overload), `Flush` | **Unchanged** — no action needed. |
104
+
105
+ ## Middleware telemetry access
106
+
107
+ In 2.x, middleware could access `RequestTelemetry` via `HttpContext.Features`:
108
+
109
+ ```csharp
110
+ // 2.x
111
+ var requestTelemetry = context.Features.Get<RequestTelemetry>();
112
+ requestTelemetry?.Properties.Add("ResponseBody", responseBody);
113
+ ```
114
+
115
+ In 3.x, `RequestTelemetry` is no longer placed in `HttpContext.Features`. Use `Activity.Current` instead:
116
+
117
+ ```csharp
118
+ // 3.x
119
+ using System.Diagnostics;
120
+
121
+ var activity = Activity.Current;
122
+ activity?.SetTag("ResponseBody", responseBody);
123
+ ```
124
+
125
+ This applies to any code that accessed `RequestTelemetry` or `DependencyTelemetry` via `HttpContext.Features.Get<T>()`.
126
+
127
+ ## Manually constructed telemetry objects
128
+
129
+ Telemetry types (`RequestTelemetry`, `DependencyTelemetry`, `TraceTelemetry`, `EventTelemetry`, `ExceptionTelemetry`, `MetricTelemetry`, `AvailabilityTelemetry`) still exist in 3.x and can be passed to `TelemetryClient.Track*(...)`. However:
130
+
131
+ - `ISupportProperties` — **Removed**. Use the typed `Properties` dictionary directly on each telemetry class.
132
+ - Type checks (`telemetry is RequestTelemetry`) in custom middleware or filters — these still compile but may not match auto-collected telemetry in contexts where the 3.x SDK uses `Activity` internally. Prefer `Activity.Current?.SetTag()` for enrichment.
133
+ - `new DependencyTelemetry(...)` with `StartOperation<DependencyTelemetry>()` — **Still works**. The dependency is correlated automatically.
134
+
135
+ ## Migration steps
136
+
137
+ 1. Update the package:
138
+ ```xml
139
+ <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="3.*" />
140
+ ```
141
+
142
+ 2. Find and replace in your code:
143
+ - `InstrumentationKey = "..."` → `ConnectionString = "InstrumentationKey=...;IngestionEndpoint=..."`
144
+ - `EnableAdaptiveSampling = false` → `SamplingRatio = 1.0f` (or set `TracesPerSecond`)
145
+ - Delete any lines setting `DeveloperMode`, `EndpointAddress`, `EnableHeartbeat`, `EnableDebugLogger`, `RequestCollectionOptions`, `DependencyCollectionOptions`, or `TelemetryInitializers`
146
+ - Delete calls to `UseApplicationInsights()`, `AddApplicationInsightsTelemetryProcessor<T>()`, `ConfigureTelemetryModule<T>()`
147
+
148
+ 3. Migrate custom telemetry types:
149
+ - Convert each `ITelemetryInitializer` implementation to a `BaseProcessor<Activity>` with `OnStart`. Register via `.AddProcessor<T>()` in the OpenTelemetry pipeline.
150
+ - Convert each `ITelemetryProcessor` implementation to a `BaseProcessor<Activity>` with `OnEnd`. To drop telemetry, clear the Recorded flag: `data.ActivityTraceFlags &= ~ActivityTraceFlags.Recorded`. Register via `.AddProcessor<T>()`.
151
+ - `TelemetryClient` mostly works in 3.x but has breaking changes: remove `IDictionary<string, double> metrics` parameter from `TrackEvent`/`TrackException`/`TrackAvailability` calls (track metrics separately via `TrackMetric()`). Replace `TrackPageView` with `TrackEvent` or `TrackRequest`. Remove `GetMetric` overloads that take `MetricConfiguration`/`MetricAggregationScope`.
152
+
153
+ 4. Build and verify — the `Enable*` flags (`EnableQuickPulseMetricStream`, `EnableDependencyTrackingTelemetryModule`, etc.) still work with the same defaults. No changes needed for those.
154
+
155
+ ## Behavior notes
156
+
157
+ - `TracesPerSecond` is the default sampling mode (effective default `5`). No configuration needed for most apps.
158
+ - Connection string resolution order: `ApplicationInsightsServiceOptions.ConnectionString` → `APPLICATIONINSIGHTS_CONNECTION_STRING` env var → `ApplicationInsights:ConnectionString` in config.
159
+
160
+ ## See also
161
+
162
+ - No-code-change migration(see in appinsights-2x-to-3x-no-code-change.md)
163
+ - AddApplicationInsightsTelemetry API reference(see in AddApplicationInsightsTelemetry.md)
164
+ - TelemetryClient breaking changes(see in TelemetryClient.md)
@@ -0,0 +1,92 @@
1
+ ---
2
+ title: Application Insights 2.x to 3.x — No-Code-Change Migration
3
+ category: migration
4
+ applies-to: 3.x
5
+ ---
6
+
7
+ # App Insights 2.x → 3.x — No Code Change
8
+
9
+ ## When this applies
10
+
11
+ Your migration requires **only a package upgrade** (no code changes) if both of these are true:
12
+
13
+ 1. You call `AddApplicationInsightsTelemetry()` with no arguments, an `IConfiguration`, or with options that only set **unchanged properties**.
14
+ 2. You do not use any **removed extension methods** (`UseApplicationInsights()`, `AddApplicationInsightsTelemetryProcessor<T>()`, `ConfigureTelemetryModule<T>()`).
15
+
16
+ ### Unchanged properties (safe to keep as-is)
17
+
18
+ | Property | Default |
19
+ |---|---|
20
+ | `ConnectionString` | `null` |
21
+ | `ApplicationVersion` | Entry assembly version |
22
+ | `EnableQuickPulseMetricStream` | `true` |
23
+ | `EnablePerformanceCounterCollectionModule` | `true` |
24
+ | `EnableDependencyTrackingTelemetryModule` | `true` |
25
+ | `EnableRequestTrackingTelemetryModule` | `true` |
26
+ | `AddAutoCollectedMetricExtractor` | `true` |
27
+ | `EnableAuthenticationTrackingJavaScript` | `false` |
28
+
29
+ If your code only uses these properties (or none at all), **and** does not use `ITelemetryInitializer` or `ITelemetryProcessor`, no code changes are needed. (`TelemetryClient` still works in 3.x — existing usage does not block a no-code-change upgrade.)
30
+
31
+ ## Migration steps
32
+
33
+ ### 1. Update the package
34
+
35
+ ```xml
36
+ <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="3.*" />
37
+ ```
38
+
39
+ ### 2. Build and run
40
+
41
+ That's it. No code changes required.
42
+
43
+ ## Examples that work without changes
44
+
45
+ **Parameterless call:**
46
+ ```csharp
47
+ using Microsoft.Extensions.DependencyInjection;
48
+
49
+ var builder = WebApplication.CreateBuilder(args);
50
+ builder.Services.AddApplicationInsightsTelemetry();
51
+ var app = builder.Build();
52
+ ```
53
+
54
+ **IConfiguration overload:**
55
+ ```csharp
56
+ using Microsoft.Extensions.DependencyInjection;
57
+
58
+ var builder = WebApplication.CreateBuilder(args);
59
+ builder.Services.AddApplicationInsightsTelemetry(builder.Configuration);
60
+ var app = builder.Build();
61
+ ```
62
+
63
+ **Options with only unchanged properties:**
64
+ ```csharp
65
+ using Microsoft.Extensions.DependencyInjection;
66
+ using Microsoft.ApplicationInsights.AspNetCore.Extensions;
67
+
68
+ var builder = WebApplication.CreateBuilder(args);
69
+ builder.Services.AddApplicationInsightsTelemetry(options =>
70
+ {
71
+ options.ConnectionString = "InstrumentationKey=...;IngestionEndpoint=...";
72
+ options.EnableQuickPulseMetricStream = true;
73
+ options.EnableDependencyTrackingTelemetryModule = true;
74
+ });
75
+ var app = builder.Build();
76
+ ```
77
+
78
+ All three examples above work identically in 2.x and 3.x.
79
+
80
+ ## What changes under the hood
81
+
82
+ Even though your code stays the same, 3.x brings these improvements automatically:
83
+
84
+ - Telemetry is now collected via OpenTelemetry — better standards alignment and ecosystem compatibility.
85
+ - `TracesPerSecond` (effective default `5`) provides rate-limited sampling out of the box. No configuration needed.
86
+ - Logging is integrated automatically — `ILogger` output is exported to Application Insights without additional setup.
87
+ - Azure resource detection (App Service, VM) happens automatically.
88
+
89
+ ## See also
90
+
91
+ - Application Insights 2.x to 3.x Code Migration(see in appinsights-2x-to-3x-code-migration.md)
92
+ - AddApplicationInsightsTelemetry API reference(see in AddApplicationInsightsTelemetry.md)
@@ -0,0 +1,190 @@
1
+ ---
2
+ title: Classic ASP.NET 2.x to 3.x Migration
3
+ category: migration
4
+ applies-to: 3.x
5
+ ---
6
+
7
+ # Classic ASP.NET 2.x → 3.x Code Migration
8
+
9
+ ## What changed
10
+
11
+ 3.x is built on OpenTelemetry internally. The NuGet package name stays the same — `Microsoft.ApplicationInsights.Web` — but the internal architecture changed. `applicationinsights.config` format is simplified, satellite packages are removed, and extensibility uses OpenTelemetry processors via `ConfigureOpenTelemetryBuilder`.
12
+
13
+ Key changes:
14
+ - `<InstrumentationKey>` → `<ConnectionString>` (connection string is **required** — 3.x throws without it)
15
+ - `<TelemetryInitializers>`, `<TelemetryModules>`, `<TelemetryProcessors>` sections → removed entirely
16
+ - `<TelemetryChannel>` section → removed (export managed by OpenTelemetry)
17
+ - 12 satellite packages → removed (functionality built into the main package)
18
+ - `TelemetryConfiguration.Active` → `TelemetryConfiguration.CreateDefault()` (returns static singleton in 3.x)
19
+ - Minimum .NET Framework: 4.5.2 → **4.6.2**
20
+ - Custom initializers/processors → OpenTelemetry processors via `ConfigureOpenTelemetryBuilder`
21
+
22
+ ## applicationinsights.config — before / after
23
+
24
+ **2.x:**
25
+ ```xml
26
+ <?xml version="1.0" encoding="utf-8"?>
27
+ <ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings">
28
+ <InstrumentationKey>00000000-0000-0000-0000-000000000000</InstrumentationKey>
29
+ <TelemetryInitializers>
30
+ <Add Type="Microsoft.ApplicationInsights.Web.WebTestTelemetryInitializer, Microsoft.AI.Web" />
31
+ <Add Type="Microsoft.ApplicationInsights.Web.SyntheticUserAgentTelemetryInitializer, Microsoft.AI.Web">
32
+ <Filters>search|spider|crawl|Bot|Monitor</Filters>
33
+ </Add>
34
+ <!-- ... more initializers ... -->
35
+ </TelemetryInitializers>
36
+ <TelemetryModules>
37
+ <Add Type="Microsoft.ApplicationInsights.Web.RequestTrackingTelemetryModule, Microsoft.AI.Web" />
38
+ <Add Type="Microsoft.ApplicationInsights.Web.ExceptionTrackingTelemetryModule, Microsoft.AI.Web" />
39
+ <Add Type="Microsoft.ApplicationInsights.DependencyCollector.DependencyTrackingTelemetryModule, Microsoft.AI.DependencyCollector" />
40
+ <!-- ... more modules ... -->
41
+ </TelemetryModules>
42
+ <TelemetryChannel Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel, Microsoft.AI.ServerTelemetryChannel">
43
+ <DeveloperMode>false</DeveloperMode>
44
+ </TelemetryChannel>
45
+ </ApplicationInsights>
46
+ ```
47
+
48
+ **3.x:**
49
+ ```xml
50
+ <?xml version="1.0" encoding="utf-8"?>
51
+ <ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings">
52
+ <ConnectionString>InstrumentationKey=...;IngestionEndpoint=https://dc.applicationinsights.azure.com/</ConnectionString>
53
+ <TracesPerSecond>5.0</TracesPerSecond>
54
+ <EnableTraceBasedLogsSampler>true</EnableTraceBasedLogsSampler>
55
+ <EnableQuickPulseMetricStream>true</EnableQuickPulseMetricStream>
56
+ <EnablePerformanceCounterCollectionModule>true</EnablePerformanceCounterCollectionModule>
57
+ <EnableDependencyTrackingTelemetryModule>true</EnableDependencyTrackingTelemetryModule>
58
+ <EnableRequestTrackingTelemetryModule>true</EnableRequestTrackingTelemetryModule>
59
+ <AddAutoCollectedMetricExtractor>true</AddAutoCollectedMetricExtractor>
60
+ </ApplicationInsights>
61
+ ```
62
+
63
+ ## Web.config changes
64
+
65
+ **Remove** `TelemetryCorrelationHttpModule` (OpenTelemetry handles correlation natively).
66
+
67
+ **Keep** `ApplicationInsightsHttpModule` — still needed in 3.x.
68
+
69
+ **Add** `TelemetryHttpModule` (from `OpenTelemetry.Instrumentation.AspNet`) — added automatically by NuGet install.
70
+
71
+ ## Satellite packages to remove
72
+
73
+ These packages are no longer needed — their functionality is built into `Microsoft.ApplicationInsights.Web` 3.x. **Remove in this order** (dependents before dependencies):
74
+
75
+ 1. `Microsoft.ApplicationInsights.WindowsServer`
76
+ 2. `Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel`
77
+ 3. `Microsoft.ApplicationInsights.DependencyCollector`
78
+ 4. `Microsoft.ApplicationInsights.PerfCounterCollector`
79
+ 5. `Microsoft.ApplicationInsights.Agent.Intercept`
80
+ 6. `Microsoft.AspNet.TelemetryCorrelation`
81
+
82
+ Also remove if present (skip any not in packages.config):
83
+ - `Microsoft.ApplicationInsights.EventCounterCollector`
84
+ - `Microsoft.Extensions.Logging.ApplicationInsights`
85
+ - `Microsoft.ApplicationInsights.Log4NetAppender`
86
+ - `Microsoft.ApplicationInsights.TraceListener`
87
+ - `Microsoft.ApplicationInsights.DiagnosticSourceListener`
88
+ - `Microsoft.ApplicationInsights.EtwCollector`
89
+ - `Microsoft.ApplicationInsights.EventSourceListener`
90
+
91
+ ## TelemetryConfiguration changes
92
+
93
+ | 2.x Pattern | 3.x Replacement |
94
+ |---|---|
95
+ | `TelemetryConfiguration.Active` | `TelemetryConfiguration.CreateDefault()` (returns static singleton) |
96
+ | `new TelemetryConfiguration(ikey)` | `TelemetryConfiguration.CreateDefault()` + set `ConnectionString` |
97
+ | `config.InstrumentationKey = "..."` | `config.ConnectionString = "InstrumentationKey=...;IngestionEndpoint=..."` |
98
+ | `config.TelemetryInitializers.Add(...)` | Use `ConfigureOpenTelemetryBuilder` — see below |
99
+ | `config.TelemetryProcessorChainBuilder` | Use `ConfigureOpenTelemetryBuilder` — see below |
100
+ | `config.TelemetryChannel` | Removed — export managed by OpenTelemetry |
101
+ | `config.TelemetrySinks` | Removed — use OpenTelemetry exporters |
102
+
103
+ ## Custom processor migration (non-DI)
104
+
105
+ In classic ASP.NET, use `ConfigureOpenTelemetryBuilder` on `TelemetryConfiguration` in `Global.asax.cs`:
106
+
107
+ ```csharp
108
+ using Microsoft.ApplicationInsights;
109
+ using Microsoft.ApplicationInsights.Extensibility;
110
+ using OpenTelemetry.Trace;
111
+ using OpenTelemetry.Logs;
112
+ using OpenTelemetry.Resources;
113
+
114
+ public class MvcApplication : HttpApplication
115
+ {
116
+ public static TelemetryClient TelemetryClient { get; private set; }
117
+
118
+ protected void Application_Start()
119
+ {
120
+ var config = TelemetryConfiguration.CreateDefault();
121
+ config.ConnectionString = "InstrumentationKey=...;IngestionEndpoint=...";
122
+ config.ConfigureOpenTelemetryBuilder(otel =>
123
+ {
124
+ otel.WithTracing(tracing =>
125
+ {
126
+ tracing.AddProcessor<MyEnrichmentProcessor>();
127
+ tracing.AddProcessor<MyFilterProcessor>();
128
+ });
129
+ otel.ConfigureResource(r => r.AddService("MyWebApp"));
130
+ });
131
+
132
+ TelemetryClient = new TelemetryClient(config);
133
+
134
+ AreaRegistration.RegisterAllAreas();
135
+ RouteConfig.RegisterRoutes(RouteTable.Routes);
136
+ }
137
+
138
+ protected void Application_End()
139
+ {
140
+ TelemetryClient?.Flush();
141
+ System.Threading.Tasks.Task.Delay(1000).Wait();
142
+ }
143
+ }
144
+ ```
145
+
146
+ > **Important:** Create a **single static** `TelemetryClient` instance in `Application_Start`. Do not create per-request or per-controller instances — this causes memory leaks and duplicate telemetry. `TelemetryConfiguration.CreateDefault()` returns a singleton that is shared with the `ApplicationInsightsHttpModule`.
147
+
148
+ See TelemetryConfigurationBuilder.md for full API details.
149
+
150
+ ## Sampling changes
151
+
152
+ - Per-type sampling (e.g. exclude exceptions from sampling) is **no longer supported**
153
+ - Default: rate-limited at 5 traces/sec via `<TracesPerSecond>`
154
+ - Fixed-rate: `<SamplingRatio>0.25</SamplingRatio>` (25%)
155
+ - Custom OTel samplers not supported with 3.x shim
156
+
157
+ ## TelemetryClient changes
158
+
159
+ See TelemetryClient.md for full breaking changes. Key items:
160
+ - `TrackPageView` — removed entirely
161
+ - `TrackEvent`/`TrackException`/`TrackAvailability` — metrics dict parameter removed
162
+ - Parameterless `new TelemetryClient()` — removed, use `new TelemetryClient(TelemetryConfiguration.CreateDefault())`
163
+ - `client.InstrumentationKey` — removed
164
+ - Create a **single static instance** — do not create per-request (see processor migration section above)
165
+
166
+ ## Migration steps
167
+
168
+ 1. Check .NET Framework target — must be **4.6.2** or later
169
+ 2. Upgrade `Microsoft.ApplicationInsights.Web` to 3.x via Package Manager Console: `Update-Package Microsoft.ApplicationInsights.Web`
170
+ 3. Remove satellite packages via Package Manager Console in this order (dependents before dependencies):
171
+ - `Microsoft.ApplicationInsights.WindowsServer`
172
+ - `Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel`
173
+ - `Microsoft.ApplicationInsights.DependencyCollector`
174
+ - `Microsoft.ApplicationInsights.PerfCounterCollector`
175
+ - `Microsoft.ApplicationInsights.Agent.Intercept`
176
+ - `Microsoft.AspNet.TelemetryCorrelation`
177
+ 4. Rewrite `applicationinsights.config` to 3.x format (remove all `<TelemetryInitializers>`, `<TelemetryModules>`, `<TelemetryProcessors>`, `<TelemetryChannel>` sections; add `<ConnectionString>` and feature flags)
178
+ 5. Update `Web.config` — remove `TelemetryCorrelationHttpModule`, verify `TelemetryHttpModule` present
179
+ 6. Replace `TelemetryConfiguration.Active` with `TelemetryConfiguration.CreateDefault()` in code
180
+ 7. Create a single static `TelemetryClient` in `Application_Start`, flush in `Application_End`
181
+ 8. Migrate custom `ITelemetryInitializer`/`ITelemetryProcessor` to OpenTelemetry processors via `ConfigureOpenTelemetryBuilder`
182
+ 9. Fix TelemetryClient breaking calls (TrackEvent metrics dict, TrackPageView, etc.)
183
+ 10. Set `<ConnectionString>` in applicationinsights.config
184
+ 11. Build and verify
185
+
186
+ ## See also
187
+
188
+ - ApplicationInsightsWeb API reference(see in ApplicationInsightsWeb.md)
189
+ - ConfigureOpenTelemetryBuilder(see in TelemetryConfigurationBuilder.md)
190
+ - TelemetryClient breaking changes(see in TelemetryClient.md)