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
