๐ 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
- Go to Azure Portal โ Search for "Log Analytics Workspaces" โ Create.
- Provide the following details:
- Subscription: Select your Azure subscription.
- Resource Group: Choose or create a new one.
- Name: Enter a unique name (e.g.,
log-corpapp-prod-uksouth). - Region: Same as your IIS VMs.
- Click "Review + Create" and deploy the workspace.
๐ Microsoft Learn: Log Analytics Workspace
Create a Data Collection Endpoint (DCE)
- Navigate to Monitor โ Data Collection Endpoints.
- Click "+ Create" and provide:
- Name: e.g.,
dce-corpapp-prod-uksouth. - Subscription & Resource Group: Same as your IIS VMs.
- Region: Same as Log Analytics Workspace.
- Review & create the endpoint.
๐ Microsoft Learn: Data Collection Endpoints
Create a Data Collection Rule (DCR)
- Go to Monitor โ Data Collection Rules โ + Create.
- Configure:
- Name:
dcr-corpapp-iis-prod-uksouth - Subscription & Resource Group: Same as above.
- Region: Same as DCE & LAW.
- Define data sources:
- Windows Event Logs: Add
System,Application, etc. - Log Levels: Select relevant levels (Error, Warning, Information).
- Set Destination:
- Choose "Log Analytics Workspace" โ Select the previously created workspace.
- Associate with IIS VMs (
WEB01-WEB05). - Review & Create the rule.
๐ Microsoft Learn: Data Collection Rules
Install the Azure Monitor Agent (AMA)
- Navigate to each IIS VM.
- Under "Monitoring", select "Extensions".
- Click "+ Add" โ AzureMonitorWindowsAgent โ Install.
- Repeat for all IIS VMs.
๐ Microsoft Learn: Azure Monitor Agent
Enable Application Insights
- Navigate to Azure Portal โ Search for "Application Insights".
- Click "+ Create" โ Provide:
- Subscription & Resource Group: Same as VMs.
- Name:
insights-corpapp-prod-uksouth-001. - Region: Same as your IIS VMs.
- Application Type: ASP.NET Web Application.
- 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
๐ Application Map
๐ Live Metrics
๐ Failures & Exceptions
๐ Performance Monitoring
๐ 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
โ 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! ๐





