In AZ-204, Application Insights is the core of the monitoring domain. It lets you see in real time how your app is actually behaving.
What Is Application Insights?
Think of Application Insights like the dashboard on your car. Just as you can glance at your speed, fuel level, and engine temperature while driving, Application Insights lets you monitor your web app's performance, errors, and usage patterns in real time.
It is a feature of Azure Monitor and is specialized as an APM (Application Performance Management) tool for web applications.
| Feature | Description | Example | |---------|-------------|---------| | Performance monitoring | Measures response time and throughput | Average API response time: 200ms | | Error tracking | Records and analyzes exceptions | 5 NullReferenceExceptions per hour | | Usage pattern analysis | Understands user behavior | 30% drop-off rate on checkout page | | Dependency monitoring | Tracks calls to external services | DB query slowness, external API delays |
Instrumentation
Instrumentation is the process of attaching "sensors" to your app. Just as a car needs physical sensors before its dashboard can display data, your app needs instrumentation code before Application Insights can collect data.
SDK Instrumentation (Manual)
Add the Application Insights SDK directly to your code for fine-grained control.
Auto-Instrumentation (Codeless)
Enable Application Insights through Azure App Service settings without modifying any code. Fast and simple, but custom events cannot be added.
Types of data collected automatically:
Requests: HTTP request and response information Dependencies: DB calls, external API calls Exceptions: Unhandled errors Page Views: Collected from the browser (requires JavaScript SDK) Custom Events: Added manually by the developer
Distributed Tracing
In a microservices environment, a single request travels through multiple services. For example, a shopping cart order flows through: Order Service → Inventory Service → Payment Service → Shipping Service.
Distributed tracing connects this entire flow with a single thread so you can track it end to end — like package tracking for deliveries, letting you see exactly which service took how long.
Key Concepts
| Concept | Description | |---------|-------------| | Application Map | Displays the calling relationships between services as a visual map | | End-to-End Transaction | Shows the full path a single request took and the time spent at each step | | Correlation ID | A unique identifier that links a request across services |
In the Application Map, each service appears as a node with connecting lines. Nodes with high error rates or slow responses are highlighted in color.
Availability Tests
Availability tests are like regular health checkups for your app. They automatically send requests to your app from multiple locations around the world and alert you if the app doesn't respond or responds too slowly.
| Test Type | Description | When to Use | |-----------|-------------|------------| | URL Ping | Sends a GET request to a URL and checks response code and time | The most basic health check | | Standard | Can check SSL certificate validity and choose HTTP method | More detailed than URL Ping | | Custom TrackAvailability | Send availability results directly from code | For complex scenarios like login flows |
Availability test results appear under the "Availability" tab, and failures can trigger email or SMS notifications through an Action Group.
Live Metrics
Live Metrics is an electrocardiogram monitor for your app — it shows the real-time heartbeat. Use it immediately after deploying a new version so you can catch problems the moment they appear.
Displays request count, response time, and CPU usage in near real time (under 1-second delay) Verify immediately after deployment whether anything is wrong Exceptions appear live in the stream as they occur
Alerts
Alerts automatically notify you when something goes wrong with your app — like a fire alarm that goes off the moment a problem is detected.
Alert Components
| Component | Role | Example | |-----------|------|---------| | Alert Rule | Defines which condition triggers the alert | Response time > 2 seconds for 5 consecutive minutes | | Condition Type | Based on a metric or a log query | CPU > 80% / Error log appears | | Action Group | What to do and who to notify when the alert fires | Email, SMS, Webhook, Azure Function |
Action Groups can be reused across multiple alert rules, making it easy to manage a single standard notification target for your whole team.
Exam Key Points
"Monitor web app performance, errors, and usage patterns" -- Application Insights (a feature of Azure Monitor)
"Enable Application Insights in App Service without code changes" -- Auto-instrumentation
"Developer records a custom business event" -- TelemetryClient.TrackEvent()
"Visualize calling relationships between microservices as a map" -- Application Map
"See the full path a single request took through all services" -- End-to-End Transaction
"Periodically send GET requests to a URL to check if the app is alive" -- URL Ping test
"Availability test for complex scenarios like login" -- TrackAvailability()
"Check requests and errors in real time right after deployment" -- Live Metrics
"Send email or SMS when a specific condition is met" -- Alert Rule + Action Group
"Reuse the same notification targets across multiple alert rules" -- Action Group