Azure Virtual Network, Virtual Machines, and Load Balancer - Complete Guide¶
Overview¶
This comprehensive guide walks through creating a complete Azure infrastructure using Terraform that includes:
- Virtual Network (VNet) with subnet configuration
- Network Security Group (NSG) with security rules
- Two Linux Virtual Machines running Ubuntu 22.04 LTS
- Azure Load Balancer distributing traffic across VMs
- Nginx web servers installed on both VMs
Architecture Diagram¶
Internet
|
v
[Public IP] (Static)
|
v
[Azure Load Balancer]
|
+-- Health Probe (Port 80)
+-- Load Balancing Rule (Port 80)
|
v
[Backend Pool]
|
+-- [VM 0] ---- [NIC 0] ---- [Private IP: 10.0.1.x]
| |
+-- [VM 1] ---- [NIC 1] ---- [Private IP: 10.0.1.y]
|
v
[Subnet: 10.0.1.0/24]
|
v
[VNet: 10.0.0.0/16]
|
v
[Network Security Group]
(Allow Port 80 Inbound)
Infrastructure Components¶
1. Resource Group¶
- Dynamically named using
random_petresource - Location: East US (configurable)
2. Networking¶
- Virtual Network: 10.0.0.0/16 address space
- Subnet: 10.0.1.0/24 address range
- Public IP: Static allocation, Standard SKU
- Network Security Group: Allows HTTP traffic (port 80)
3. Compute¶
- 2 Linux VMs: Ubuntu 22.04 LTS
- VM Size: Standard_B2s (configurable)
- Storage: Standard LRS OS disks
- Authentication: Password-based (randomly generated if not provided)
4. Load Balancing¶
- Load Balancer: Standard SKU, public-facing
- Backend Pool: Contains both VMs
- Health Probe: Monitors port 80
- Load Balancing Rule: Distributes HTTP traffic
- Outbound Rule: Manages outbound connectivity
5. Application¶
- Nginx: Installed via VM extension
- Custom Page: Displays hostname for identification
Documentation Structure¶
This guide is organized into the following sections:
- 10.0-Overview.md (This file) - Architecture overview and introduction
- 10.1-Resource-Group-Setup.md - Resource group creation with random naming
- 10.2-Virtual-Network-Setup.md - VNet, subnet, and NSG configuration
- 10.3-Network-Interfaces.md - NIC creation and configuration
- 10.4-Virtual-Machines-Setup.md - VM deployment and configuration
- 10.5-Load-Balancer-Setup.md - Load balancer components and rules
- 10.6-VM-Extensions.md - Nginx installation and configuration
- 10.7-Terraform-Variables.md - Variable definitions and customization
- 10.8-Outputs.md - Output values and accessing the application
- 10.9-Deployment-Guide.md - Step-by-step deployment instructions
Prerequisites¶
- Azure subscription
- Terraform installed (version supporting azurerm ~>4.0)
- Azure CLI installed and authenticated
- Basic understanding of Azure networking concepts
Key Features¶
- High Availability: Two VMs behind a load balancer
- Automatic Scaling Ready: Infrastructure supports adding more VMs
- Security: NSG controls inbound traffic
- Monitoring: Health probes ensure VM availability
- Automation: Fully automated deployment with Terraform
- Customization: Extensive variable support for configuration
Next Steps¶
Proceed to 10.1-Resource-Group-Setup.md to begin the detailed walkthrough of each component.