Monitoring Azure App Service
Effective monitoring is crucial for understanding the health, performance, and usage of your Azure App Service. Azure provides a comprehensive suite of tools and services to help you monitor your applications, diagnose issues, and optimize performance.
Key Monitoring Capabilities
Azure App Service integrates seamlessly with several Azure monitoring services. The primary tools and features you'll leverage include:
Azure Monitor
Azure Monitor is the foundational service for collecting, analyzing, and acting on telemetry from your Azure and on-premises environments. For App Service, it provides insights into:
- Metrics: Key performance indicators like CPU time, memory usage, HTTP requests, data in/out, and more. These can be visualized in dashboards and used for alerting.
- Logs: Application logs, web server logs, deployment logs, and diagnostic logs can be collected and queried using Kusto Query Language (KQL) in Log Analytics.
- Alerts: Configure alerts based on metric thresholds or log query results to notify you of potential issues.
- Application Insights: A powerful extension of Azure Monitor for application performance management (APM). It provides deep insights into application behavior, traces, exceptions, and dependencies.

Application Insights
Application Insights, part of Azure Monitor, offers advanced capabilities for application-level monitoring:
- Performance Monitoring: Track response times, request rates, and identify bottlenecks.
- Exception Tracking: Capture and analyze exceptions occurring in your application.
- Dependency Tracking: Monitor calls to external services (databases, APIs) to identify performance issues in connected systems.
- Live Metrics Stream: See near real-time metrics for your application as they happen.
- Availability Tests: Configure tests to check if your web application is available from various global locations.
Configuring Diagnostics and Logging
To gain detailed insights, you need to configure diagnostic settings for your App Service:
- Navigate to your App Service in the Azure portal.
- In the left-hand menu, under "Monitoring," select "Diagnostic settings."
- Click "Add diagnostic setting."
- Select the logs and metrics you want to collect. Common choices include:
- AppServiceHTTPLogs
- AppServiceAppLogs
- AppServiceConsoleLogs
- AppServiceAuditLogs
- Deployment
- Web server logs
- Choose a destination for your logs, such as a Log Analytics workspace, Storage Account, or Event Hub. A Log Analytics workspace is recommended for advanced querying and analysis.
- Save the diagnostic setting.
Setting Up Alerts
Proactive alerting is key to maintaining application uptime and performance. You can set up alerts in Azure Monitor based on various conditions:
- Metric Alerts: Trigger an alert when a specific metric (e.g., CPU percentage, memory working set) exceeds or falls below a defined threshold for a specified period.
- Log Alerts: Execute a Kusto query on your Log Analytics data and trigger an alert if the query returns results or the count exceeds a threshold. This is useful for detecting specific error patterns or events.
// Example Kusto Query for detecting HTTP 5xx errors
AppServiceHTTPLogs
| where sc-status >= 500 and sc-status <= 599
| summarize count() by cs-uri-stem, bin(timeGenerated, 5m)
| where count_ > 5
When an alert is triggered, you can configure actions such as sending an email, triggering a webhook, or running an Azure Function.
Monitoring Application Performance with Kudu
The Kudu service provides a command-line interface and debugging tools for your App Service. It's a valuable resource for:
- Accessing Logs: Directly view log files generated by your application and the web server.
- Process Explorer: See running processes, their CPU and memory usage.
- Environment Variables: Inspect the environment your application is running in.
You can access Kudu by appending "/DebugConsole" or "/SCM" to your App Service URL (e.g., your-app-name.scm.azurewebsites.net
).
Best Practices for Monitoring
- Define Performance Baselines: Understand what normal performance looks like for your application to easily identify deviations.
- Monitor Key Metrics: Focus on metrics that directly impact user experience and application health (e.g., request latency, error rates, CPU/memory usage).
- Implement Comprehensive Logging: Ensure your application logs sufficient detail for debugging.
- Configure Meaningful Alerts: Set up alerts that provide actionable insights and avoid alert fatigue.
- Regularly Review Logs and Metrics: Don't just set up monitoring; actively use the data to proactively identify and resolve issues.
- Utilize Application Insights: For .NET, Java, Node.js, and other supported languages, Application Insights provides the deepest application-level visibility.