liveBook · Manning

Application Insights

As explained in Building Web APIs with ASP.NET Core

Application Insights is an Azure monitoring service that ingests, monitors, and analyzes logs, status messages, and performance telemetry from applications and services.

Application Insights is an Azure logging provider for storing application events in a structured format. It gives the MyBGList web API a cloud-based destination for logs and performance-related telemetry. section 7.3.3

Set up the provider by completing these practical steps:

  • Create an Application Insights instance through a Microsoft Azure account. section 7.3.3
  • Retrieve the instance connection string and place it under Azure:ApplicationInsights:ConnectionString. section 7.3.3
  • Install Microsoft.Extensions.Logging.ApplicationInsights and Microsoft.ApplicationInsights.AspNetCore, both shown at version 2.21.0. section 7.3.3
  • Register Application Insights with the logging builder, optionally retaining console and debug providers for local verification. section 7.3.3
"Azure": {
    "ApplicationInsights": {
      "ConnectionString": "<INSERT_CONNECTION_STRING_HERE>"   #1
    }
  }

Use the configuration listing to verify the connection-string location and replace its placeholder with the retrieved value. section 7.3.3

builder.Logging
  .ClearProviders()
  .AddSimpleConsole()
  .AddDebug()
.AddApplicationInsights(              #1
telemetry => telemetry.ConnectionString =
builder
.Configuration["Azure:ApplicationInsights:ConnectionString"],
loggerOptions => { });

Use the logging-builder listing to compare provider registration and connection-string binding in the web API. section 7.3.3

How Building Web APIs with ASP.NET Core covers it

How deep it goes
Explains account creation, connection-string configuration, package installation, and provider registration, but stops short of deeper telemetry analysis.
Examples
Uses the MyBGList web API, Azure configuration, NuGet commands, logging-builder registration, and Application Insights trace events.
What it assumes
Assumes a web API with logging and requires an Azure account; introduces the Azure platform and Application Insights from their basic purpose.
What you can do after
Configure Application Insights as a logging provider and verify that application logs reach the Azure service.
How it connects
Connects Azure Application Insights with Azure Monitor, structured logging, logging providers, and cloud services.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building Web APIs with ASP.NET Core. The section links point to the parts of the book it draws on.