.NET

In .NET applications, the only thing you have to do to get started is to install the latest Microsoft.ApplicationInsights package. The easiest way is to use the following code snippet:

TelemetryConfiguration.Active.InstrumentationKey = "<instrumentation-key>";var telemetryClient = new TelemetryClient();

This code does two things:

  • Sets the current configuration by providing an instrumentation key. It is all that is needed to connect to a service.
  • Initializes an instance of TelemetryClient—this class is a proxy to a service, which enables you to communicate with it.

Then you can use different methods to log some data:

telemetryClient.TrackTrace("Hello World!");telemetryClient.TrackException(new Exception());telemetryClient.TrackDependency(new ...

Get Hands-On Azure for Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.