Network Watcher and Network Monitoring

Watch the video to deepen your understanding.
SubscribeComplete the full lesson to earn 25 points — 50 with Pro
Work through each section, then tap “Mark as Complete” on the last one.
✦ Skip the page breaks, the wait, and see fewer ads — read each lesson on a single page with Pro
Network Watcher and Network Monitoring
Introduction: The Imperative of Network Visibility in Azure
In the dynamic landscape of cloud computing, maintaining robust network connectivity, performance, and security is paramount. Azure, with its vast array of services and complex networking capabilities, requires specialized tools to ensure that your virtual networks (VNets) and the resources within them operate as expected. Without proper network monitoring, diagnosing connectivity issues, identifying performance bottlenecks, or detecting security threats can be like searching for a needle in a haystack.
This is where Azure Network Watcher comes in. Network Watcher is a regional service that provides a suite of tools to monitor, diagnose, and view metrics and logs for Azure IaaS (Infrastructure-as-a-Service) resources. It's not just about knowing if your VMs are up; it's about understanding how traffic flows to, from, and within your Azure environment, ensuring compliance, and proactively identifying potential issues before they impact your users.
In this lesson, we will explore the capabilities of Azure Network Watcher, understand its core features, see practical examples of its use, and learn how to integrate it into a comprehensive network monitoring strategy.
Understanding Azure Network Watcher
Azure Network Watcher is designed to simplify network troubleshooting and provide deep insights into your Azure network configuration. It acts as a central hub for various diagnostic and visualization tools, operating at the VNet level. When you enable Network Watcher in a region, it automatically deploys and manages agents (where necessary) to collect data and perform diagnostics.
Key Capabilities of Network Watcher
Network Watcher offers a comprehensive set of features, each designed to address a specific aspect of network monitoring and diagnostics:
- Topology: Visualizes the network resources in a VNet, their interconnections, and relationships.
- Connection Monitor: Monitors end-to-end connectivity and latency between a source and a destination, providing historical data and alerts.
- IP Flow Verify: Checks if a packet is allowed or denied by Network Security Groups (NSGs) for a specific VM, source, destination, and port.
- NSG Flow Logs: Logs all IP traffic flowing through an NSG, providing detailed information about source/destination IPs, ports, protocols, and allow/deny decisions.
- Packet Capture: Captures network traffic to and from an Azure VM, allowing for deep-packet inspection and analysis.
- Next Hop: Determines the next hop for traffic from a VM, helping diagnose routing issues (e.g., with User Defined Routes - UDRs).
- VPN Diagnostics: Provides diagnostics for Azure VPN gateways and connections.
- Troubleshoot Connectivity: A simplified, on-demand connectivity check between two endpoints.
Network Watcher Scope
Network Watcher is a regional service. You must enable it in each region where you have Azure virtual networks that you wish to monitor. Once enabled, it can monitor all resources within that region's VNets.
Core Features and Practical Examples
Let's delve into some of the most critical features of Network Watcher with practical examples and code snippets.
1. Topology
The Topology feature provides a visual representation of your network resources within a VNet. It helps you understand the layout, connectivity, and relationships between VMs, subnets, NSGs, and other networking components.
Practical Example: Imagine you have a complex VNet with multiple subnets, peered VNets, and various VMs. The Topology view can quickly show you which VMs are in which subnet, which NSGs are applied, and how traffic might flow.
How to Access: Azure Portal -> Network Watcher -> Topology (under Monitoring). Select your subscription, resource group, and virtual network.
2. Connection Monitor
Connection Monitor is an invaluable tool for continuous, end-to-end network performance monitoring. It allows you to monitor connectivity between Azure VMs, Azure VMs and on-premises machines, or even between Azure VMs and public endpoints. It provides historical data on latency, packet loss, and connection failures, along with network topology and component status.
Practical Example: You have an Azure web server (VM1) that needs to communicate with a backend database server (VM2) in a different subnet. You want to ensure continuous connectivity and low latency between them.
# Prerequisites: Ensure Network Watcher is enabled in the region
# Example: Enable Network Watcher in East US
az network watcher configure --resource-group NetworkWatcherRG --locations eastus
# Define variables
$SourceVmName = "VM1"
$SourceVmResourceGroup = "WebAppRG"
$DestinationIP = (Get-AzVM -Name "VM2" -ResourceGroupName "DatabaseRG").PrivateIPAddress
$DestinationPort = 1433 # SQL Server port
$ConnectionMonitorName = "WebAppToDBMonitor"
$NetworkWatcherRG = "NetworkWatcherRG"
$NetworkWatcherLocation = "eastus"
# Get Network Watcher instance
$nw = Get-AzNetworkWatcher -ResourceGroupName $NetworkWatcherRG -Location $NetworkWatcherLocation
# Create Connection Monitor endpoint for source VM
$source = New-AzNetworkWatcherConnectionMonitorEndpointObject -Name "SourceVM" `
-ResourceGroup $SourceVmResourceGroup -VMName $SourceVmName
# Create Connection Monitor endpoint for destination IP/Port
$destination = New-AzNetworkWatcherConnectionMonitorEndpointObject -Name "DestinationDB" `
-Address $DestinationIP -Port $DestinationPort
# Create Connection Monitor test configuration (e.g., TCP with specific interval)
$testConfiguration = New-AzNetworkWatcherConnectionMonitorTestConfigurationObject `
-Name "TCPTest" -Protocol "TCP" -TestFrequencyInSeconds 60 `
-PreferredIPVersion "IPv4" -Port 1433 `
-SuccessThresholdChecksFailedPercent 20 -SuccessThresholdRoundTripTimeMs 300
# Create Connection Monitor group
$testGroup = New-AzNetworkWatcherConnectionMonitorTestGroupObject `
-Name "WebToDBTestGroup" -Source $source -Destination $destination `
-TestConfiguration $testConfiguration
# Create the Connection Monitor
New-AzNetworkWatcherConnectionMonitor -NetworkWatcher $nw `
-Name $ConnectionMonitorName -Location $NetworkWatcherLocation `
-TestGroup $testGroup -OutputType "Workspace" `
-WorkspaceResourceId "/subscriptions/YOUR_SUBSCRIPTION_ID/resourceGroups/LogAnalyticsRG/providers/Microsoft.OperationalInsights/workspaces/MyLogAnalyticsWorkspace"
Write-Host "Connection Monitor '$ConnectionMonitorName' created successfully."
Connection Monitor Output
Connection Monitor data can be sent to Log Analytics Workspace for advanced querying, alerting, and visualization. This is highly recommended for production environments.
3. IP Flow Verify
IP Flow Verify helps you determine if a packet is allowed or denied to or from a VM due to NSG rules. This is crucial for troubleshooting connectivity issues where NSGs might be blocking legitimate traffic.
Practical Example: A user reports they cannot RDP into an Azure VM (VM3). You suspect an NSG rule is blocking the traffic.
# Define variables
$VmName = "VM3"
$VmResourceGroup = "ManagementRG"
$Direction = "Inbound"
$Protocol = "TCP"
$LocalIPAddress = (Get-AzVM -Name $VmName -ResourceGroupName $VmResourceGroup).PrivateIPAddress
$LocalPort = 3389 # RDP port
$RemoteIPAddress = "203.0.113.10" # Example user's public IP
$RemotePort = 50000 # Example ephemeral port
$NetworkWatcherRG = "NetworkWatcherRG"
$NetworkWatcherLocation = "eastus"
# Get Network Watcher instance
$nw = Get-AzNetworkWatcher -ResourceGroupName $NetworkWatcherRG -Location $NetworkWatcherLocation
# Run IP Flow Verify
$flowVerify = Test-AzNetworkWatcherIPFlow `
-NetworkWatcher $nw `
-TargetVirtualMachineId (Get-AzVM -Name $VmName -ResourceGroupName $VmResourceGroup).Id `
-Direction $Direction -Protocol $Protocol `
-LocalIPAddress $LocalIPAddress -LocalPort $LocalPort `
-RemoteIPAddress $RemoteIPAddress -RemotePort $RemotePort
# Output results
Write-Host "IP Flow Verify Result for VM '$VmName':"
Write-Host "Access: $($flowVerify.Access)"
Write-Host "Rule Name: $($flowVerify.RuleName)"
The output will tell you if the traffic is Allow or Deny and the name of the NSG rule responsible for that decision.
4. NSG Flow Logs
NSG Flow Logs provide detailed information about IP traffic flowing through an NSG. These logs are invaluable for auditing, security analysis, and understanding traffic patterns. They capture source/destination IP addresses, ports, protocols, traffic direction, and whether the traffic was allowed or denied.
Practical Example: You want to monitor all inbound and outbound traffic for your web application's NSG to detect unusual activity or identify unneeded open ports.
# Define variables
$NsgName = "WebAppNSG"
$NsgResourceGroup = "WebAppRG"
$StorageAccountName = "nsgflowlogsstorage" # Must be globally unique
$StorageAccountRG = "LogStorageRG"
$LogAnalyticsWorkspaceName = "MyLogAnalyticsWorkspace"
$LogAnalyticsWorkspaceRG = "LogAnalyticsRG"
$Location = "eastus"
# Create a storage account for flow logs (if it doesn't exist)
New-AzStorageAccount -ResourceGroupName $StorageAccountRG -Name $StorageAccountName `
-Location $Location -SkuName Standard_LRS -Kind StorageV2
# Get the NSG resource ID
$nsgId = (Get-AzNetworkSecurityGroup -Name $NsgName -ResourceGroupName $NsgResourceGroup).Id
# Get the Storage Account resource ID
$storageId = (Get-AzStorageAccount -Name $StorageAccountName -ResourceGroupName $StorageAccountRG).Id
# Get the Log Analytics Workspace resource ID (optional, but recommended)
$logAnalyticsId = (Get-AzOperationalInsightsWorkspace -Name $LogAnalyticsWorkspaceName -ResourceGroupName $LogAnalyticsWorkspaceRG).Id
# Enable NSG Flow Logs with Version 2 and send to Storage Account and Log Analytics
Set-AzNetworkWatcherConfigFlowLog `
-Location $Location -NetworkSecurityGroupId $nsgId `
-StorageId $storageId -EnableFlowLog $true `
-FormatType JSON -FormatVersion 2 `
-RetentionEnabled $true -RetentionDays 30 `
-TrafficAnalyticsEnabled $true -WorkspaceResourceId $logAnalyticsId
Write-Host "NSG Flow Logs enabled for NSG '$NsgName'."
Traffic Analytics
When enabling NSG Flow Logs, consider enabling Traffic Analytics. This feature processes NSG Flow Log data into rich visualizations and actionable insights within Azure Monitor Log Analytics, making it easier to understand traffic patterns and identify anomalies.
5. Packet Capture
Packet Capture allows you to capture network traffic to and from an Azure VM. This is invaluable for deep-level network diagnostics, protocol analysis, and application-level troubleshooting.
Practical Example: An application on VM4 is experiencing intermittent connection issues to an external service. You need to capture the exact network packets to analyze the communication handshake and identify the root cause.
# Define variables
$VmName = "VM4"
$VmResourceGroup = "AppServerRG"
$NetworkWatcherRG = "NetworkWatcherRG"
$NetworkWatcherLocation = "eastus"
$StorageAccountName = "packetcapturestorage" # Must be globally unique
$StorageAccountRG = "LogStorageRG"
$PacketCaptureName = "VM4AppTroubleshoot"
$DurationInSeconds = 300 # Capture for 5 minutes
# Create a storage account for packet capture (if it doesn't exist)
New-AzStorageAccount -ResourceGroupName $StorageAccountRG -Name $StorageAccountName `
-Location $NetworkWatcherLocation -SkuName Standard_LRS -Kind StorageV2
# Get Network Watcher instance
$nw = Get-AzNetworkWatcher -ResourceGroupName $NetworkWatcherRG -Location $NetworkWatcherLocation
# Get VM object
$vm = Get-AzVM -Name $VmName -ResourceGroupName $VmResourceGroup
# Start Packet Capture
Start-AzNetworkWatcherPacketCapture `
-NetworkWatcher $nw -TargetVirtualMachineId $vm.Id `
-Name $PacketCaptureName -StorageAccountResourceId (Get-AzStorageAccount -Name $StorageAccountName -ResourceGroupName $StorageAccountRG).Id `
-TimeLimitInSeconds $DurationInSeconds
Write-Host "Packet capture '$PacketCaptureName' started on VM '$VmName'."
Write-Host "Captured data will be saved to storage account '$StorageAccountName'."
After the capture finishes, you can download the .cap file from the specified storage account and analyze it using tools like Wireshark.
Integrating with Azure Monitor and Log Analytics
While Network Watcher provides powerful diagnostic tools, its
Reach the last section to complete this lesson and earn points — you're on section 1 of 3.
- Introduction to Azure Monitor
- Azure Monitor Architecture and Data Sources
- Configuring Log Analytics Workspaces
- Designing Log Routing Solutions
- Configuring Diagnostic Settings
- Application Insights for Solution Architects
- Network Watcher and Network Monitoring
- Azure Monitor Alerts and Action Groups
- Workbooks and Custom Dashboards
- Designing a Comprehensive Monitoring Strategy
- Logging and Monitoring Quiz5q
- Microsoft Entra ID for Solution Architects
- Designing Identity Solutions: B2B Collaboration
- Designing Identity Solutions: B2C Scenarios
- Conditional Access Policy Design
- Designing for Multi-Factor Authentication
- Managed Identities for Azure Resources
- Service Principals and App Registrations
- Role-Based Access Control Design
- Privileged Identity Management
- Microsoft Entra ID Protection
- Zero Trust Architecture with Microsoft Entra
- Authentication and Authorization Quiz5q
- Introduction to Azure Governance
- Designing Management Group Hierarchies
- Subscription Strategy Design
- Resource Group Organization Patterns
- Azure Policy Design and Assignment
- Custom Policy Definitions and Initiatives
- Resource Locks and Tagging Strategies
- Azure Blueprints and Landing Zones
- Cost Management and Budget Design
- Cloud Adoption Framework for Governance
- Governance Solutions Quiz5q
- Introduction to Azure Storage
- Storage Account Types and Replication
- Blob Storage Tiers and Lifecycle Management
- Azure Files and Azure NetApp Files
- Azure Managed Disks Design
- Azure Data Lake Storage Gen2
- Cosmos DB Consistency Models
- Cosmos DB Partitioning and Throughput Design
- Cosmos DB API Selection Guide
- Table Storage and Queue Storage Design
- Storage Security and Encryption
- Non-Relational Storage Quiz5q
- Azure SQL Database Service Tiers
- Azure SQL Managed Instance Design
- Azure Database for MySQL and PostgreSQL
- Database Scaling: Vertical and Horizontal
- Read Replicas and Geo-Replication
- Database Security and Auditing Design
- Transparent Data Encryption and Always Encrypted
- Caching with Azure Cache for Redis
- Azure SQL Elastic Pools Design
- Relational Storage Quiz5q
- Azure Data Factory Design Patterns
- Data Integration Pipeline Architecture
- Azure Synapse Analytics Design
- Azure Databricks Integration Patterns
- Azure Stream Analytics for Real-Time Data
- Azure Event Hubs for Data Ingestion
- Data Migration Strategies and Tools
- Azure Purview for Data Governance
- Data Integration Quiz5q
- Introduction to High Availability in Azure
- Availability Zones and Availability Sets
- Azure Load Balancer Design
- Application Gateway and WAF Design
- Azure Front Door and Global Load Balancing
- Azure Traffic Manager Routing Methods
- Multi-Region Architecture Design
- SLA Design and Composite SLAs
- Health Probes and Failover Configuration
- Azure Service Fabric for Stateful HA
- High Availability Quiz5q
- Azure Backup Architecture and Vaults
- Backup Policies for VMs and Databases
- Azure Site Recovery Design
- RTO and RPO Planning Strategies
- Geo-Redundant and Cross-Region Recovery
- Hybrid and On-Premises Backup Solutions
- Resiliency Patterns and Chaos Engineering
- Disaster Recovery Testing and Drills
- Azure Immutable Backup and Soft Delete
- Backup and Disaster Recovery Quiz5q
- Introduction to Azure Compute Options
- Virtual Machine Design and Sizing
- VM Scale Sets and Autoscaling Strategies
- Azure Batch for Large-Scale Workloads
- Azure App Service Plans and Design
- App Service Environments and Isolation
- Azure Container Instances
- Azure Kubernetes Service Architecture
- AKS Networking and Storage Design
- Azure Functions and Serverless Design
- Durable Functions and Orchestration
- Compute Decision Framework
- Azure Virtual Desktop Design
- Compute Solutions Quiz5q
- Microservices Architecture Patterns
- Azure API Management Design
- Azure Service Bus Messaging Design
- Azure Event Grid and Event-Driven Architecture
- Azure Event Hubs for Streaming
- Azure Logic Apps and Integration Workflows
- Azure SignalR and Web PubSub
- Caching Strategies and Azure CDN
- App Configuration and Feature Flags
- Designing for Scalability and Performance
- Azure Container Apps Design
- Application Architecture Quiz5q
- Virtual Network Design and Address Planning
- Subnet Design and Network Segmentation
- Hub-Spoke Network Topology
- Azure Virtual WAN Design
- VPN Gateway Design and Configuration
- ExpressRoute Circuit Design
- Network Security Groups Design
- Azure Firewall and Firewall Manager
- Azure DDoS Protection Design
- Private Endpoints and Private Link
- Azure DNS and DNS Architecture
- Network Performance and Traffic Routing
- Azure Bastion and Secure Access
- Network Solutions Quiz5q
- Azure Migrate Overview and Assessment
- Migration Assessment and Discovery
- Azure Cloud Adoption Framework for Migration
- VM Migration with Azure Migrate
- Database Migration with Azure DMS
- Application Migration to App Service
- Containerizing Applications for Migration
- Migration Cost Planning and Optimization
- Data Box and Offline Migration Methods
- Migrations Quiz5q
Enjoying the courses?
Everything stays free. Pro shows fewer ads, doubles the points you earn on every lesson and quiz so you progress twice as fast, unlocks half of every practice exam — plus full case studies — with the Learn & Exam study modes, and lets you read each lesson on one page.
- ✓ Fewer advertisements
- ✓ 2× points per lesson & quiz
- ✓ 50% of every exam unlocked
- ✓ Learn & Exam modes
- ✓ Distraction-free lessons