Skip to content

Application Insights

📊 Monitoring an IIS-Based Web Farm with Azure Application Insights

In this guide, you'll learn how to:

✅ Set up Application Insights on an IIS-based web farm.
✅ Configure Log Analytics, Data Collection Rules, and Data Collection Endpoints.
✅ Use PowerShell to install the Application Insights agent.
✅ Monitor live metrics, failures, performance, and logs in real-time.

By the end, you'll have a fully monitored IIS-based web farm using Azure! 🎯


🏗️ Step 1: Enabling Application Insights on IIS Servers

To effectively monitor your IIS-based application, you need to configure Azure Application Insights and ensure all required components are installed on your Azure VMs.

🛠️ Prerequisites

Before proceeding, ensure you have:

  • An active Azure Subscription with permissions to create and manage resources.
  • A Log Analytics Workspace (LAW) to store collected telemetry data.
  • Azure Monitor Agent (AMA) installed on your IIS VMs.
  • Necessary permissions to create Data Collection Rules (DCRs) and Data Collection Endpoints (DCEs).

Create a Log Analytics Workspace

  1. Go to Azure PortalSearch for "Log Analytics Workspaces"Create.
  2. Provide the following details:
  3. Subscription: Select your Azure subscription.
  4. Resource Group: Choose or create a new one.
  5. Name: Enter a unique name (e.g., log-corpapp-prod-uksouth).
  6. Region: Same as your IIS VMs.
  7. Click "Review + Create" and deploy the workspace.

🔗 Microsoft Learn: Log Analytics Workspace

Create a Data Collection Endpoint (DCE)

  1. Navigate to MonitorData Collection Endpoints.
  2. Click "+ Create" and provide:
  3. Name: e.g., dce-corpapp-prod-uksouth.
  4. Subscription & Resource Group: Same as your IIS VMs.
  5. Region: Same as Log Analytics Workspace.
  6. Review & create the endpoint.

🔗 Microsoft Learn: Data Collection Endpoints

Create a Data Collection Rule (DCR)

  1. Go to MonitorData Collection Rules+ Create.
  2. Configure:
  3. Name: dcr-corpapp-iis-prod-uksouth
  4. Subscription & Resource Group: Same as above.
  5. Region: Same as DCE & LAW.
  6. Define data sources:
  7. Windows Event Logs: Add System, Application, etc.
  8. Log Levels: Select relevant levels (Error, Warning, Information).
  9. Set Destination:
  10. Choose "Log Analytics Workspace" → Select the previously created workspace.
  11. Associate with IIS VMs (WEB01 - WEB05).
  12. Review & Create the rule.

🔗 Microsoft Learn: Data Collection Rules

Install the Azure Monitor Agent (AMA)

  1. Navigate to each IIS VM.
  2. Under "Monitoring", select "Extensions".
  3. Click "+ Add"AzureMonitorWindowsAgent → Install.
  4. Repeat for all IIS VMs.

🔗 Microsoft Learn: Azure Monitor Agent

Enable Application Insights

  1. Navigate to Azure PortalSearch for "Application Insights".
  2. Click "+ Create" → Provide:
  3. Subscription & Resource Group: Same as VMs.
  4. Name: insights-corpapp-prod-uksouth-001.
  5. Region: Same as your IIS VMs.
  6. Application Type: ASP.NET Web Application.
  7. Click "Review + Create" and deploy.

🔗 Microsoft Learn: Enable Application Insights

Install the Application Insights Agent

Use the following PowerShell script to install the agent on all of the IIS servers:

# Install the Application Insights Agent
$instrumentationKey = "YOUR-INSTRUMENTATION-KEY"
Install-PackageProvider -Name NuGet -Force
Install-Module -Name ApplicationInsightsWebTracking -Force
Enable-ApplicationInsightsMonitoring -InstrumentationKey $instrumentationKey
Restart-Service W3SVC

📊 Step 2: Using Application Insights for Monitoring

With everything set up, it's time to monitor and analyze application performance! 🔍

📌 Overview Dashboard

  • Displays high-level health metrics, failed requests, and response times. 📸 Insights Overview

📌 Application Map

  • Shows dependencies and interactions between components. 📸 Application Map

📌 Live Metrics

  • Monitor real-time requests, server performance, and failures. 📸 Live Metrics

📌 Failures & Exceptions

  • Identify and diagnose failed requests & top exceptions. 📸 Failures & Exceptions

📌 Performance Monitoring

  • Analyze response times, dependencies & bottlenecks. 📸 Performance Overview

📌 Logs & Queries

  • Run Kusto Query Language (KQL) queries for deep insights.

Example query to find failed requests:

requests
| where timestamp > ago(24h)
| where success == false
| project timestamp, name, resultCode, url
| order by timestamp desc

📸 Query Results


Next Steps

🎯 Continue monitoring logs & alerts for trends.
🎯 Optimize Application Insights sampling to reduce telemetry costs.
🎯 Automate reporting for key performance metrics.

By following this guide, you'll have a robust, real-time monitoring setup for your IIS web farm, ensuring optimal performance and quick issue resolution! 🚀

Share on Share on