Azure Virtual Networks
Azure Virtual Networks (VNets) are the foundational building blocks for your private network in Azure. They enable you to create your own isolated network space in the cloud, allowing you to run virtual machines, services, and applications with enhanced security and control.
What are Azure Virtual Networks?
An Azure Virtual Network is a logical representation of your network in Azure. It's a logically isolated network that you define, offering features similar to a traditional on-premises network, but with the scalability, availability, and flexibility of the Azure cloud.
Key Components
Azure VNets are comprised of several essential components that work together to provide network functionality:
IP Addressing
Each VNet is assigned a private IP address space, which is a range of IP addresses from RFC 1918 (e.g., 10.0.0.0/16, 172.16.0.0/12, 192.168.0.0/16). You can define a single, contiguous IP address space or multiple non-overlapping address spaces.
Example: A VNet might have the address space 10.1.0.0/16.
Subnets
You can divide your VNet's IP address space into smaller segments called subnets. Each subnet is a range of IP addresses within the VNet's address space. Resources within Azure are deployed into subnets.
Dividing your VNet into subnets allows for segmentation and isolation of resources. For instance, you might have a subnet for web servers, another for application servers, and a third for databases.
Example: Within the 10.1.0.0/16 VNet, you could have:
- 10.1.1.0/24for Web Servers
- 10.1.2.0/24for App Servers
- 10.1.3.0/24for Databases
Network Security Groups (NSGs)
NSGs act as a distributed firewall, allowing you to filter network traffic to and from Azure resources in an Azure virtual network. You can associate an NSG with subnets or individual network interfaces (NICs).
NSGs contain a list of security rules that allow or deny inbound network traffic to, or outbound network traffic from, various types of Azure resources.
Example Rules:
- Allow inbound RDP (port 3389) from a specific IP address.
- Deny all inbound traffic to a database subnet except from the application server subnet.
- Allow outbound HTTP/HTTPS traffic.
User-Defined Routes (UDRs)
UDRs allow you to override Azure's default system routes. This is crucial for scenarios where you need to route traffic through a network virtual appliance (NVA), such as a firewall or a security gateway, before it reaches its destination.
You define a route table and then associate it with one or more subnets.
Example: Route all outbound internet traffic from a subnet to a firewall NVA deployed in another subnet.
VNet Peering
VNet peering connects two or more Azure VNets privately and securely through the Azure backbone network. It allows virtual machines in different VNets to communicate with each other as if they were in the same network.
Peering can be done within the same Azure region (local VNet peering) or across different Azure regions (global VNet peering).
- No gateway required: Traffic between peered VNets is routed directly through the Azure backbone, not over the public internet.
- Low latency, high bandwidth: Optimized for performance.
Connectivity Options
Azure VNets facilitate various connectivity patterns:
- To the internet: Resources in a VNet can connect to the internet via an Azure-provided public IP address or through NAT gateways.
- To on-premises networks:
                - Site-to-Site VPN: Connects your on-premises network to your VNet using a secure VPN tunnel.
- ExpressRoute: Provides a private, dedicated connection from your on-premises network to Azure.
 
- Between VNets: As described with VNet Peering.
- To other Azure services: Securely connect to Azure PaaS services like Azure SQL Database, Azure Storage, etc., using Private Endpoints or Service Endpoints.
Best Practices
Address Space Planning: Carefully plan your VNet IP address spaces to avoid overlaps and ensure sufficient room for future growth. Use private IP address ranges.
- Subnetting Strategy: Design subnets to align with security boundaries and application tiers. Avoid overly large subnets.
- NSG Implementation: Apply the principle of least privilege. Create specific rules rather than broad ones, and associate NSGs at the subnet level where possible for easier management.
- Route Tables: Use UDRs judiciously to control traffic flow, especially when integrating with NVAs.
- VNet Peering: Leverage VNet peering for secure and efficient communication between VNets. Understand transit routing limitations.
- Network Monitoring: Utilize Azure Network Watcher to monitor, diagnose, and view metrics for your VNet resources.
- Hybrid Connectivity: Choose the right connectivity method (VPN vs. ExpressRoute) based on your bandwidth, latency, and security requirements.
Azure Virtual Networks provide a robust and flexible foundation for building secure, scalable, and interconnected cloud solutions.