Application Insights
Application Insights is application performance monitoring (APM): it shows which requests are slow, which dependencies fail and why.
On this page · 5 min · Intermediate
On this page
- Learning objectives
- Explanation
- Code example
- Step by step
- Real-world use
- Common mistakes
- Best practices
- Remember this
- Practice exercise
- Mini quiz
- Related topics
- My notes
- Reading time
- 5 min
- Difficulty
- Intermediate
- Updated
- Oct 29, 2026
Related tutorials
Learning objectives#
- Add Application Insights with the OpenTelemetry distro
- Explore requests, dependencies and failures
- Use the application map and live metrics
- Query telemetry with KQL
Explanation#
Application Insights is part of Azure Monitor. It records requests, dependency calls (SQL, HTTP, storage), exceptions, traces and custom events.
For ASP.NET Core, the Azure Monitor OpenTelemetry distro adds collection in one line. Configure it with the APPLICATIONINSIGHTS_CONNECTION_STRING setting.
The application map shows how components call each other; transaction search follows a single request end to end; live metrics shows what is happening right now.
Code example: One line of setup#
// dotnet add package Azure.Monitor.OpenTelemetry.AspNetCore
using Azure.Monitor.OpenTelemetry.AspNetCore;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddOpenTelemetry().UseAzureMonitor(); // reads APPLICATIONINSIGHTS_CONNECTION_STRING
builder.Services.AddControllers();
var app = builder.Build();
app.MapControllers();
app.Run();
// KQL: slowest operations in the last hour
// requests
// | where timestamp > ago(1h)
// | summarize avgMs = avg(duration), calls = count() by name
// | order by avgMs desc
name avgMs calls GET Products/GetAll 412.7 1,204 POST Orders/Create 238.1 312 GET Products/Get 35.4 3,880
This example is illustrative. Copy or download it and run it in your own environment; the expected output is shown above.
Step-by-step explanation#
- UseAzureMonitor collects requests, dependencies, logs and exceptions automatically.
- The connection string comes from configuration, so it differs per environment.
- The KQL query ranks operations by average duration to find the slowest endpoint.
Real-world use case#
A slow product page is traced to one SQL query that takes 400 ms; adding an index fixes it, confirmed by the same dashboard.
Common mistakes#
Telemetry is stored and searchable. Never log passwords, tokens or full card numbers.
Very high-traffic apps can generate a lot of data. Use sampling and set a daily cap.
Best practices#
- Use one Application Insights resource per app per environment
- Use the OpenTelemetry distro for new apps
- Add custom events for key business actions
- Set up availability tests and alerts
Remember this#
Requests + dependencies + exceptions = the full story of a slow page.
One line: AddOpenTelemetry().UseAzureMonitor().
Never log secrets.
Practice exercise#
Your task: Write a KQL query listing the most common exception types in the last 24 hours.
Show solution
exceptions
| where timestamp > ago(24h)
| summarize count() by type
| order by count_ desc
Mini quiz#
Which telemetry type records outbound calls to SQL or HTTP APIs?
Want more? Practise all Microsoft Azure MCQs · Microsoft Azure interview questions
My notes#
Saved in this browser.