Skip to content

Announcement: InstrumentationKey based APIs are marked Obsolete. #2560

@TimothyMothra

Description

@TimothyMothra

Deprecating Instrumentation Key based SDK configuration in favor of Connection String.

More information:

Summary of Changes

  • Microsoft.ApplicationInsights

    • TelemetryConfiguration
      Setting InstrumentationKey via constructor or via property is marked Obsolete.
      Use the default constructor and set the ConnectionString property instead.

    • TelemetryClient
      Setting InstrumentationKey property is marked Obsolete.
      Use the constructor to provide a TelemetryConfiguration with ConnectionString set.

  • Microsoft.Extensions.Logging.ApplicationInsights

    • Setting InstrumentationKey via AddApplicationInsights() extension method is marked Obsolete.
      Use the overload which accepts Action<TelemetryConfiguration> and set TelemetryConfiguration.ConnectionString.
  • Microsoft.ApplicationInsights.AspNetCore and Microsoft.ApplicationInsights.WorkerService

    • ApplicationInsightsServiceOptions
      The InstrumentationKey property is marked Obsolete.
      Use ConnectionString property instead.

    • ExtensionMethods

      • Setting InstrumentationKey via AddApplicationInsightsTelemetry() extension method is marked Obsolete.
        Use the overload which accepts Action<ApplicationInsightsServiceOptions> and set ApplicationInsightsServiceOptions.ConnectionString.

      • Setting InstrumentationKey via AddApplicationInsightsTelemetryWorkerService() extension method is marked Obsolete.
        Use the overload which accepts Action<ApplicationInsightsServiceOptions> and set ApplicationInsightsServiceOptions.ConnectionString.

      • Setting InstrumentationKey via AddApplicationInsightsSettings() extension method is marked Obsolete.
        Use the overload which accepts string connectionString.

Config files

Users should refrain from setting the InstrumentationKey in text-based config files and instead set the ConnectionString.

ApplicationInsights.config

<?xml version="1.0" encoding="utf-8"?>
<ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings">
    <ConnectionString>InstrumentationKey=00000000-0000-0000-0000-000000000000</ConnectionString>
</ApplicationInsights>

ASP.NET Core or Worker Service config:

{
  "ApplicationInsights": {
    "ConnectionString" : "InstrumentationKey=00000000-0000-0000-0000-000000000000;"
    }
  }

For Comments or Questions

Please open a new issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions