Application Insights
Application Insights is Azure's APM (Application Performance Monitoring) service — the recommended way to monitor App Service apps. Once enabled, it automatically collects:
- Request telemetry — Every HTTP request: URL, response time, status code, user
- Exceptions — All unhandled exceptions with stack traces
- Dependencies — Outbound calls to databases, APIs, storage with timing
- Custom events and metrics — Track business events from your code
- Live Metrics — Real-time stream of requests, failures, and performance
Built-in Metrics
App Service exposes metrics in Azure Monitor — viewable in the Metrics blade:
| Metric | What It Measures | Alert On |
|---|---|---|
| CPU Percentage | Average CPU usage across instances | >80% sustained |
| Memory Working Set | Current memory usage | >85% of available |
| Http 5xx | Server error rate | Any increase above baseline |
| Http 4xx | Client error rate | Sudden spikes |
| Average Response Time | Time to serve requests | Above SLA threshold |
| Requests | Total requests per second | For capacity planning |
| Http Queue Length | Requests waiting to be processed | >0 for extended period |
Diagnostic Logs
Enable diagnostic logging (App Service → Monitoring → App Service logs) to capture:
| Log Type | What It Contains | Storage |
|---|---|---|
| Application logging | Console.log / logging framework output from your app code | File system or Blob Storage |
| Web server logging | IIS/HTTP access logs — every request with status, bytes, IP | File system or Blob Storage |
| Detailed error messages | Full HTML error pages for HTTP 4xx/5xx errors | File system |
| Failed request tracing | Detailed trace of each failed request (IIS trace) | File system |
Log Streaming
Stream application logs in real-time to your terminal — like tailing a log file. Useful for immediate debugging without accessing the file system:
# Stream app logs
az webapp log tail \
--name mywebapp-2026 \
--resource-group myRG
# Stream with filter
az webapp log tail \
--name mywebapp-2026 \
--resource-group myRG \
--provider http
Health Check
Configure a health check endpoint path (e.g., /health) that App Service pings every minute. If an instance returns non-2xx responses for multiple checks, App Service:
- Removes the unhealthy instance from the load balancer
- Attempts to restart it
- If still unhealthy after restart, replaces it with a new instance (Premium and above)
# Set health check path
az webapp config set \
--name mywebapp-2026 \
--resource-group myRG \
--generic-configurations '{"healthCheckPath":"/health"}'
Kudu — Advanced Tools
Kudu is the deployment and debugging console for App Service — accessible at https://mywebapp.scm.azurewebsites.net. It provides:
- Debug console — CMD/Bash access to the app's file system
- Process Explorer — View running processes, CPU/memory per process
- Log files — Browse diagnostic log files
- Environment variables — View all app settings injected into the environment
- Deployment history — View and manage past deployments
- REST API — Automate deployments and diagnostics
Diagnose and Solve Problems
The built-in "Diagnose and solve problems" blade (App Service → Diagnose and solve problems) provides guided diagnosis for common issues — availability, performance, configuration problems. It automatically analyses recent metrics, logs, and deployments to identify likely root causes.
Setting Up Alerts
# Create metric alert for 5xx errors
az monitor metrics alert create \
--name Http5xxAlert \
--resource-group myRG \
--scopes /subscriptions//resourceGroups/myRG/providers/Microsoft.Web/sites/mywebapp-2026 \
--condition "avg Http5xx > 5" \
--window-size 5m \
--evaluation-frequency 1m \
--action myActionGroup