This document outlines the breaking changes when migrating from Application Insights SDK 2.x to 3.x (Shimmed version using OpenTelemetry).
IMPORTANT: Mixing 2.x and 3.x packages is not supported. All Application Insights packages in your application must be upgraded to 3.x together.
Version 3.x represents a fundamental architectural shift:
- 2.x: Custom telemetry pipeline with processors, initializers, channels, and modules
- 3.x: Built on OpenTelemetry with Azure Monitor Exporter as the backend
The 3.x version maintains most public APIs for backward compatibility but uses OpenTelemetry and Azure Monitor Exporter internally.
The following packages are part of the shimmed 3.x release:
- Microsoft.ApplicationInsights (Core SDK)
- Microsoft.ApplicationInsights.AspNetCore (ASP.NET Core integration)
- Microsoft.ApplicationInsights.WorkerService (Worker Service integration)
- Microsoft.ApplicationInsights.NLogTarget (NLog integration)
- Microsoft.ApplicationInsights.Web (Classic ASP.NET integration)
3.x will throw an exception if a connection string is not provided. For test scenarios, one could supply a dummy string like: InstrumentationKey=00000000-0000-0000-0000-000000000000.
- Parameterless constructor removed
- 2.x:
TelemetryClient()- UsedTelemetryConfiguration.Active(obsolete) - 3.x: Removed - Must use
TelemetryClient(TelemetryConfiguration)
- 2.x:
- InstrumentationKey property setter removed
- 2.x:
public string InstrumentationKey { get; set; } - 3.x: Property completely removed from public API
- Migration: Use
TelemetryConfiguration.ConnectionStringinstead
- 2.x:
- PageView tracking removed entirely
TrackPageView(string name)TrackPageView(PageViewTelemetry telemetry)TrackEventorTrackRequestcan be used in lieu of TrackPageView in dotnet components.
- 2.x:
TrackEvent(string eventName, IDictionary<string, string> properties, IDictionary<string, double> metrics) - 3.x:
TrackEvent(string eventName, IDictionary<string, string> properties)Metrics parameter removed
- 2.x:
TrackAvailability(string name, DateTimeOffset timeStamp, TimeSpan duration, string runLocation, bool success, string message, IDictionary<string, string> properties, IDictionary<string, double> metrics) - 3.x:
TrackAvailability(string name, DateTimeOffset timeStamp, TimeSpan duration, string runLocation, bool success, string message, IDictionary<string, string> properties)Metrics parameter removed
- 2.x:
TrackException(Exception exception, IDictionary<string, string> properties, IDictionary<string, double> metrics) - 3.x:
TrackException(Exception exception, IDictionary<string, string> properties)Metrics parameter removed
- 2.x:
TrackDependency(string dependencyName, string data, DateTimeOffset startTime, TimeSpan duration, bool success)[Obsolete] - 3.x: Overload removed entirely
Recommendation for metrics: Track metrics separately via TrackMetric().
All GetMetric overloads have been simplified:
MetricConfigurationparameter removed from all overloadsMetricAggregationScopeparameter removed from all overloads Metrics configuration and aggregation is now internally managed by OpenTelemetry meters.
Examples:
-
2.x:
GetMetric(MetricIdentifier metricIdentifier, MetricConfiguration metricConfiguration, MetricAggregationScope aggregationScope) -
3.x:
GetMetric(MetricIdentifier metricIdentifier) -
2.x:
GetMetric(string metricId, string dimension1Name, MetricConfiguration metricConfiguration, MetricAggregationScope aggregationScope) -
3.x:
GetMetric(string metricId, string dimension1Name)
This applies to all dimension combinations (1D, 2D, 3D, 4D).
In 3.x, Application Insights uses OpenTelemetry internally to emit metrics. As a result, the name parameter in TrackMetric and the metricId / metricNamespace parameters in GetMetric and MetricIdentifier must now adhere to the OpenTelemetry Instrument Name Syntax:
- Must not be null or empty.
- Must be case-insensitive, ASCII strings.
- The first character must be an alphabetic character (
A-Zora-z). - Subsequent characters must be alphanumeric (
A-Z,a-z,0-9),_,.,-, or/. - Maximum length of 255 characters.
This applies to:
TrackMetric(string name, double value, ...)— thenameparameterGetMetric(string metricId, ...)— themetricIdparameterMetricIdentifier(string metricNamespace, string metricId, ...)— bothmetricNamespaceandmetricIdparameters
Track(ITelemetry telemetry)- Still exists with[EditorBrowsable(EditorBrowsableState.Never)]attribute. In 3.x, it routes to specific Track methods (TrackRequest, TrackDependency, etc.) instead of using the telemetry processor pipeline.StartOperation<T>andStopOperation<T>- Extension methods inTelemetryClientExtensionsnow use OpenTelemetry Activities instead of the legacy correlation system.
TelemetryConfiguration.Active: Initialize via TelemetryConfiguration.CreateDefault() insteadInstrumentationKey- Replaced byConnectionStringTelemetryInitializers- See detailed migration information hereTelemetryProcessors- See detailed migration information hereTelemetryProcessorChainBuilder- See detailed migration information hereTelemetryChannel- See detailed migration information hereApplicationIdProvider- See detailed migration information here.EndpointContainer- In 3.x, the connection string is parsed to determine where to send telemetry.ExperimentalFeatures- No longer neededTelemetrySinks- See detailed migration information hereDefaultTelemetrySink- See detailed migration information here
TelemetryConfiguration(string instrumentationKey)TelemetryConfiguration(string instrumentationKey, ITelemetryChannel channel)Migration note: TelemetryConfiguration.CreateDefault is the recommended way to initialize.
CreateFromConfiguration(string config)- Static method that created a TelemetryConfiguration from XML configuration string. UseCreateDefault()and set properties directly.
- CreateDefault() returns an internal static configuration instead of a new TelemetryConfiguration()
SamplingRatio(float?) - Gets or sets the sampling ratio for traces (0.0 to 1.0). A value of 1.0 means all telemetry is sent.TracesPerSecond(double?) - Gets or sets the number of traces per second for rate-limited sampling (default sampling mode).StorageDirectory(string) - Gets or sets the directory for offline telemetry storage.DisableOfflineStorage(bool?) - Gets or sets whether offline storage is disabled.EnableLiveMetrics(bool?) - Gets or sets whether Live Metrics is enabled.EnableTraceBasedLogsSampler(bool?) - Gets or sets whether trace-based log sampling is enabled.ConfigureOpenTelemetryBuilder(Action<IOpenTelemetryBuilder> configure)- Allows extending OpenTelemetry configurationSetAzureTokenCredential(TokenCredential tokenCredential)- Call this method to enable Azure Active Directory (AAD) authentication for Application Insights ingestion
Several TelemetryContext sub-context properties have been made internal, and some previously public properties have been removed.
Important
Context properties set on TelemetryClient.Context are applied to all traces and logs (TrackRequest, TrackDependency, TrackTrace, TrackEvent, TrackException, TrackAvailability). Metrics are not enriched with context properties.
InstrumentationKey- Removed. UseTelemetryConfiguration.ConnectionStringinstead.Flags- Removed from public API as there isn't equivalent configuration in the underlying exporter.Properties(obsolete) - Was obsoleted in 2.x in favor ofGlobalProperties.TryGetRawObject()/StoreRawObject()- Removed. These methods were used to pass raw objects between collectors and initializers, which no longer exist.
The following properties on sub-context classes have been made internal:
Device.OemName— Now internal. The Application Insights ingestion service does not surface this field in workspace-based resources.Session.IsFirst— Now internal. The Application Insights ingestion service does not surface this field in workspace-based resources.Operation.Id— Now internal. Correlation IDs are managed automatically by OpenTelemetry.Operation.ParentId— Now internal. Correlation IDs are managed automatically by OpenTelemetry.Operation.CorrelationVector— Now internal. No longer needed due to shift to OpenTelemetry correlation.
All sub-context classes remain public. The following properties remain public and can be set on TelemetryClient.Context (applies to all non-metric telemetry) or on individual telemetry items:
Cloud(RoleName,RoleInstance)Component(Version)User(Id,AuthenticatedUserId,AccountId,UserAgent)Operation(Name,SyntheticSource)Location(Ip)Session(Id)Device(Type,Id,OperatingSystem,Model)GlobalProperties
See detailed migration guidance here
AddApplicationInsightsTelemetry(string instrumentationKey)- Obsolete overload removedAddApplicationInsightsKubernetesEnricher()- Kubernetes enrichment removed; there is a resource detector for enriching telemetry that is implemented internally.
UseApplicationInsightsRequestTelemetry()- Obsolete middleware removedUseApplicationInsightsExceptionTelemetry()- Obsolete middleware removed
UseApplicationInsights()- All overloads removed (were obsolete in 2.x)
AddApplicationInsightsTelemetryProcessor<T>()- See more detailed migration guidance hereAddApplicationInsightsTelemetryProcessor(Type telemetryProcessorType)- See more detailed migration guidance hereConfigureTelemetryModule<T>(Action<T> configModule)- Module configuration without options (was already obsolete in 2.x)ConfigureTelemetryModule<T>(Action<T, ApplicationInsightsServiceOptions> configModule)- Use one of the retained methods or set options via appsettings.json.AddApplicationInsightsSettings(bool? developerMode, string endpointAddress, string instrumentationKey)- Was already obsolete in 2.xAddApplicationInsightsSettings(string connectionString, bool? developerMode, string endpointAddress, string instrumentationKey)- Use one of the retained methods or set options via appsettings.json. The connection string specifies endpoints and batching of telemetry is internally managed by the underlying exporter. However, TelemetryClient.Flush() can still be used.
The following extension methods remain with identical signatures:
AddApplicationInsightsTelemetry()AddApplicationInsightsTelemetry(IConfiguration configuration)AddApplicationInsightsTelemetry(Action<ApplicationInsightsServiceOptions> configureOptions)AddApplicationInsightsTelemetry(ApplicationInsightsServiceOptions options)
ExceptionTrackingMiddleware- Middleware class removed, was already obsoleteHostingDiagnosticListener- this was previously internalResources- Previously public APIs now set to internal. These were autogenerated APIs not directly used by customers in 2.x.Resources.Culture(get/set)Resources.JavaScriptAuthSnippet(get)Resources.JavaScriptSnippet(get)Resources.ResourceManager(get)
AspNetCoreEnvironmentTelemetryInitializerAzureAppServiceRoleNameFromHostNameHeaderInitializerClientIpHeaderTelemetryInitializerDomainNameRoleInstanceTelemetryInitializerHttpDependenciesParsingTelemetryInitializerOperationNameTelemetryInitializerWebSessionTelemetryInitializerTelemetryInitializerBase
Please see detailed migration guidance here
The following ITelemetryModule implementations were previously registered via AddApplicationInsightsTelemetry() in 2.x. In 3.x, their functionality is either handled internally or removed:
RequestTrackingTelemetryModule— Request tracking is now handled internally via OpenTelemetry ASP.NET Core instrumentation. Configurable viaEnableRequestTrackingTelemetryModule.DiagnosticsTelemetryModule— Removed. Self-diagnostics and heartbeat are internally implemented in 3.x.AppServicesHeartbeatTelemetryModule— Removed. 3.x internally uses a resource detector to emit resource attributes.AzureInstanceMetadataTelemetryModule— Removed. 3.x internally uses a resource detector to emit resource attributes.PerformanceCollectorModule— Performance counter collection is now internally managed. Configurable viaEnablePerformanceCounterCollectionModule.QuickPulseTelemetryModule— Live Metrics is now internally managed. Configurable viaEnableQuickPulseMetricStream.DependencyTrackingTelemetryModule— Dependency tracking is now handled internally via OpenTelemetry instrumentation. Configurable viaEnableDependencyTrackingTelemetryModule.EventCounterCollectionModule— Discontinued. There is no direct replacement.
The ConfigureTelemetryModule<T>() extension method has also been removed. Use ApplicationInsightsServiceOptions properties or appsettings.json to configure the retained toggles listed above.
InstrumentationKey- Obsolete property removed (useConnectionString)DeveloperMode- Batching of telemetry is now internally managed by the underlying exporter, with no equivalent toggle. However, TelemetryClient.Flush() can still be used in testing scenarios to flush telemetry.EndpointAddress- No longer needed (ConnectionStringcontains endpoint information)TelemetryInitializers- See detailed migration guidance hereEnableHeartbeat- Heartbeat configuration removed as the 3.x internally maintains its own heartbeating mechanism.RequestCollectionOptions- See detailed migration guidance hereDependencyCollectionOptions- See detailed migration guidance hereEnableAdaptiveSampling- Removed in favor of our internal rate limited sampler, which is now the default sampling behavior.EnableDebugLogger- Removed as internal self diagnostics accomplishes the same goal. Instructions to enable here.
ConnectionString- Primary configuration methodApplicationVersionAddAutoCollectedMetricExtractorEnableQuickPulseMetricStreamEnableAuthenticationTrackingJavaScript- JavaScript auth tracking configEnableDependencyTrackingTelemetryModule- Dependency tracking toggleEnablePerformanceCounterCollectionModule- Performance counter toggleEnableRequestTrackingTelemetryModule- Request tracking toggle
Credential(Azure.Core.TokenCredential) - Enables Azure Active Directory (AAD) authenticationTracesPerSecond(double?) - Gets or sets the number of traces per second for rate-limited sampling (default sampling mode). ReplacesEnableAdaptiveSampling.SamplingRatio(float?) - Gets or sets the sampling ratio for traces (0.0 to 1.0). A value of 1.0 means all telemetry is sent.EnableTraceBasedLogsSampler(bool?) - Gets or sets whether trace-based log sampling is enabled (default: true). When enabled, logs are sampled based on the sampling decision of the associated trace.
Please see our migration guide for detailed guidance on sampling.
2.x:
public JavaScriptSnippet(
TelemetryConfiguration telemetryConfiguration,
IOptions<ApplicationInsightsServiceOptions> serviceOptions,
IHttpContextAccessor httpContextAccessor,
JavaScriptEncoder encoder = null)3.x:
public JavaScriptSnippet(
TelemetryConfiguration telemetryConfiguration,
IOptions<ApplicationInsightsServiceOptions> serviceOptions,
IHttpContextAccessor httpContextAccessor = null, // Now optional
JavaScriptEncoder encoder = null)AddApplicationInsightsTelemetryWorkerService(string instrumentationKey)- Instrumentation key overload removed (was obsolete in 2.x)
The following extension methods remain with identical signatures:
AddApplicationInsightsTelemetryWorkerService()AddApplicationInsightsTelemetryWorkerService(IConfiguration configuration)AddApplicationInsightsTelemetryWorkerService(Action<ApplicationInsightsServiceOptions> configureOptions)AddApplicationInsightsTelemetryWorkerService(ApplicationInsightsServiceOptions options)
The following ITelemetryModule implementations were previously registered via AddApplicationInsightsTelemetryWorkerService() in 2.x. In 3.x, their functionality is either handled internally or removed:
DiagnosticsTelemetryModule— Removed. Self-diagnostics and heartbeat are internally implemented in 3.x.AppServicesHeartbeatTelemetryModule— Removed. 3.x internally uses a resource detector to emit resource attributes.AzureInstanceMetadataTelemetryModule— Removed. 3.x internally uses a resource detector to emit resource attributes.PerformanceCollectorModule— Performance counter collection is now internally managed. Configurable viaEnablePerformanceCounterCollectionModule.QuickPulseTelemetryModule— Live Metrics is now internally managed. Configurable viaEnableQuickPulseMetricStream.DependencyTrackingTelemetryModule— Dependency tracking is now handled internally via OpenTelemetry instrumentation. Configurable viaEnableDependencyTrackingTelemetryModule.EventCounterCollectionModule— Discontinued. There is no direct replacement.
The ConfigureTelemetryModule<T>() extension method has also been removed. Use ApplicationInsightsServiceOptions properties or appsettings.json to configure the retained toggles listed above.
InstrumentationKey- Obsolete property removed (useConnectionString)EnableEventCounterCollectionModule- EventCounter module configuration removed. There is no intended replacement.EnableAppServicesHeartbeatTelemetryModule- 3.x internally calls a resource detector that emits resource attributes to an internal resource metric.EnableAzureInstanceMetadataTelemetryModule- 3.x internally calls a resource detector that emits resource attributes to an internal resource metric.EnableHeartbeat- 3.x internally emits a heartbeat metric by default.EnableDiagnosticsTelemetryModule- Removed in favor of self diagnostics and internally implemented heartbeat.DeveloperMode- Batching of telemetry is now internally managed by the underlying exporter, with no equivalent toggle. However, TelemetryClient.Flush() can still be used in testing scenarios to flush telemetry.EndpointAddress- No longer configurable (ConnectionStringcontains endpoints)DependencyCollectionOptions- See detailed migration guidance hereEnableAdaptiveSampling- Removed in favor of our internal rate limited sampler, which is now the default sampling mechanism.EnableDebugLogger- Removed in favor of self diagnostics. Learn how to enable here.
ConnectionStringApplicationVersionEnableDependencyTrackingTelemetryModule- Enabled by defaultEnablePerformanceCounterCollectionModule- Enabled by defaultEnableQuickPulseMetricStream- Live metrics collection is enabled by defaultAddAutoCollectedMetricExtractor- Standard metrics collection is enabled by default.
Credential(Azure.Core.TokenCredential) - Enables Azure Active Directory (AAD) authenticationTracesPerSecond(double?) - Gets or sets the number of traces per second for rate-limited sampling (default sampling mode). ReplacesEnableAdaptiveSampling.SamplingRatio(float?) - Gets or sets the sampling ratio for traces (0.0 to 1.0). A value of 1.0 means all telemetry is sent.EnableTraceBasedLogsSampler(bool?) - Gets or sets whether trace-based log sampling is enabled (default: true). When enabled, logs are sampled based on the sampling decision of the associated trace.
Please see our migration guide for detailed guidance on sampling.
InstrumentationKeyproperty (string)- 2.x:
public string InstrumentationKey { get; set; } - 3.x: Completely removed
- Migration: Use
ConnectionStringproperty instead
- 2.x:
Credential(Azure.Core.TokenCredential) - Enables Azure Active Directory (AAD) authentication for Application Insights
Migration Required: Users MUST update their NLog configuration:
2.x Configuration:
<target type="ApplicationInsightsTarget" InstrumentationKey="xxx" />3.x Configuration:
<target type="ApplicationInsightsTarget" ConnectionString="InstrumentationKey=xxx;IngestionEndpoint=https://..." />- 2.x:
net452,netstandard2.0 - 3.x:
net462,net8.0 - Breaking: Minimum .NET Framework version raised from 4.5.2 → 4.6.2
- Breaking:
netstandard2.0replaced withnet8.0
Critical Actions Required:
- Replace
InstrumentationKeywithConnectionStringin NLog configuration - Ensure connection string is always provided (no longer optional)
- Update minimum .NET Framework from 4.5.2 to 4.6.2 if using .NET Framework
The following modules have been removed:
RequestTrackingTelemetryModule- This is replaced by an internal ActivityFilterProcessor and is configurable via<EnabledRequestTrackingTelemetryModule>ExceptionTrackingTelemetryModule- Exception tracking is automatically included via OpenTelemetry instrumentation. No action needed from customer side.AspNetDiagnosticTelemetryModule- OpenTelemtry's ASPNET instrumentation is automatically enabled in 3.x
Note that the applicationinsights.config configuration for and its sub-settings have been removed in favor of alternatives above.
All public TelemetryInitializers from 2.x are REMOVED from the public API in 3.x. Please refer to the migration guidance for the list previous initalizers and their replacements.
WebTelemetryInitializerBaseWebTelemetryModuleBaseOpenTelemetry Processors are meant to provide extensibility. See more detailed guidance in migration documentation.
HttpContextExtensionclass removed from public API: The intended replacement is for customers to register a custom activity processor via TelemetryConfiguration.ConfigureOpenTelemetryBuilder().HttpContextBaseExtension: was previously marked obsolete, now completely removed.
See migration guidance for how to create a custom activity processor and register it.
<ApplicationInsights>
<InstrumentationKey>your-key-here</InstrumentationKey>
<TelemetryInitializers>
<Add Type="Microsoft.ApplicationInsights.Web.WebTestTelemetryInitializer, Microsoft.AI.Web" />
<Add Type="Microsoft.ApplicationInsights.Web.SyntheticUserAgentTelemetryInitializer, Microsoft.AI.Web">
<Filters>search|spider|crawl|Bot|Monitor|AlwaysOn</Filters>
</Add>
<Add Type="Microsoft.ApplicationInsights.Web.ClientIpHeaderTelemetryInitializer, Microsoft.AI.Web" />
<!-- ... 7 more initializers ... -->
</TelemetryInitializers>
<TelemetryModules>
<Add Type="Microsoft.ApplicationInsights.Web.RequestTrackingTelemetryModule, Microsoft.AI.Web">
<Handlers>...</Handlers>
</Add>
<Add Type="Microsoft.ApplicationInsights.Web.ExceptionTrackingTelemetryModule, Microsoft.AI.Web" />
<Add Type="Microsoft.ApplicationInsights.Web.AspNetDiagnosticTelemetryModule, Microsoft.AI.Web" />
</TelemetryModules>
</ApplicationInsights><ApplicationInsights>
<ConnectionString>InstrumentationKey=your-key;IngestionEndpoint=https://...</ConnectionString>
<DisableTelemetry>false</DisableTelemetry>
<ApplicationVersion>1.0.0</ApplicationVersion>
<SamplingRatio>1.0</SamplingRatio>
<TracesPerSecond>5</TracesPerSecond>
<StorageDirectory>C:\Logs</StorageDirectory>
<DisableOfflineStorage>false</DisableOfflineStorage>
<EnableQuickPulseMetricStream>true</EnableQuickPulseMetricStream>
<EnableTraceBasedLogsSampler>false</EnableTraceBasedLogsSampler>
<EnablePerformanceCounterCollectionModule>true</EnablePerformanceCounterCollectionModule>
<AddAutoCollectedMetricExtractor>true</AddAutoCollectedMetricExtractor>
<EnableDependencyTrackingTelemetryModule>true</EnableDependencyTrackingTelemetryModule>
<EnableRequestTrackingTelemetryModule>true</EnableRequestTrackingTelemetryModule>
</ApplicationInsights>Summary of config changes:
<TelemetryInitializers>section no longer supported<TelemetryModules>section no longer supported<InstrumentationKey>replaced with<ConnectionString>- Multiple new configuration elements supported (see example above)
- ASPNET & exception telemetry modules are now autoconfigured to use OpenTelemetry instrumentation.
- 2.x:
net452(Targets .NET Framework 4.5.2) - 3.x:
net462(Targets .NET Framework 4.6.2) - Breaking: Minimum framework version raised from 4.5.2 → 4.6.2