AZ-204 - Troubleshoot Solutions by Using Application Insights
Configure an App to Use Application Insights
Application Insights is a feature of Azure Monitor that provides application performance management (APM) and monitoring for live web applications. It automatically detects performance anomalies and includes analytics tools to diagnose issues.
Setup Methods
Auto-Instrumentation (Codeless)
Enable Application Insights from the Azure Portal without modifying application code. Supported for App Service, Azure Functions, and VMs running .NET, Java, Node.js, or Python.
SDK-Based (Code-Level)
Add the Application Insights SDK to your application for full control over telemetry collection, custom events, custom metrics, and dependency tracking.
Connection String
Application Insights uses a connection string (containing the instrumentation key and ingestion endpoint) to send telemetry data. Store this in app settings, not hard-coded in source.
Telemetry Types
| Type | Description |
|---|---|
| Requests | HTTP requests received by your app (response time, status code) |
| Dependencies | Calls to external services (SQL, HTTP, Azure services) |
| Exceptions | Unhandled and handled exceptions with stack traces |
| Page Views | Client-side page load telemetry for web apps |
| Custom Events | User-defined events for tracking business-specific actions |
| Custom Metrics | Numeric measurements like queue length, processing time |
| Traces | Diagnostic log messages (via ILogger, Log4j, etc.) |
Monitor and Analyze Metrics, Logs, and Traces
Live Metrics
Live Metrics Stream
Real-time view of incoming requests, dependency calls, exceptions, and custom metrics with approximately 1 second latency. Useful for monitoring deployments and live incidents.
Log Analytics (KQL)
Application Insights stores telemetry in a Log Analytics workspace. Use Kusto Query Language (KQL) to analyze data.
| where timestamp > ago(24h)
| where resultCode == "500"
| summarize count() by operation_Name
| order by count_ desc
Application Map
Application Map
A visual representation of your application's components and their dependencies. Shows health status, failure rates, and response times for each component. Helps identify bottlenecks and failures across distributed systems.
Alerts
Configure alerts based on metrics (e.g., response time > 5 sec) or log queries (e.g., error count > 10 in 5 minutes). Actions include email, SMS, webhook, Azure Function, or Logic App.
Availability Tests
Ping your application from Azure datacenters worldwide at regular intervals. Alert when the application is down or responding slowly.
Key Terms
| Term | Definition |
|---|---|
| Application Insights | An APM feature of Azure Monitor for monitoring live web application performance, detecting anomalies, and diagnosing issues. |
| Instrumentation Key | A unique identifier (part of the connection string) that routes telemetry to the correct Application Insights resource. |
| KQL (Kusto Query Language) | The query language used to analyze log data in Application Insights and Log Analytics. |
| Application Map | A visual diagram of application components and dependencies, showing health, failure rates, and response times. |
| Live Metrics | A real-time monitoring stream with ~1 second latency showing incoming requests, dependencies, and exceptions. |
| Availability Test | Periodic health checks of your application from Azure datacenters worldwide. |
- Application Insights is part of Azure Monitor -- not a standalone service.
- Connection string is preferred over instrumentation key alone for configuration.
- KQL is required for custom log queries. Know basic syntax: where, summarize, count(), ago().
- Application Map is the go-to tool for visualizing distributed application dependencies.
- Auto-instrumentation = codeless setup from Azure Portal. SDK = code-level for custom telemetry.
- Availability tests monitor uptime from multiple global locations.
Practice Questions
Q1. Which Application Insights feature provides a visual representation of your application's components and their dependencies?
- Live Metrics Stream
- Application Map
- Log Analytics
- Availability Tests
Answer: B
Application Map provides a visual diagram showing all components, dependencies, health status, failure rates, and response times across your distributed application.
Q2. What query language is used to analyze Application Insights log data?
- SQL
- GraphQL
- KQL (Kusto Query Language)
- T-SQL
Answer: C
KQL (Kusto Query Language) is the query language used to analyze data in Application Insights and Log Analytics workspaces.
Q3. A developer wants to track a business-specific action like 'user completed checkout'. Which telemetry type should they use?
- Request
- Dependency
- Custom Event
- Trace
Answer: C
Custom events are user-defined telemetry for tracking business-specific actions. Use TrackEvent() in the SDK to record these events.
Q4. Which setup method allows enabling Application Insights without modifying application code?
- SDK-Based instrumentation
- Auto-instrumentation (codeless)
- Manual telemetry injection
- Log forwarding
Answer: B
Auto-instrumentation (codeless) enables Application Insights from the Azure Portal without any code changes. It is supported for App Service, Azure Functions, and VMs running supported runtimes.
Q5. What is the recommended way to configure the Application Insights connection in an Azure App Service?
- Hard-code the instrumentation key in source code
- Store the connection string in app settings
- Use a SAS token
- Configure it in the web.config file
Answer: B
The connection string should be stored in app settings (APPLICATIONINSIGHTS_CONNECTION_STRING), not hard-coded in source code, for security and manageability.
AZ-204 Developing Azure Solutions - Table of Contents
Master all exam topics with comprehensive study guides and practice questions.