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 ...