Mini Azure Project – Build Virtual Network & Subnets via Azure CLI
This mini-lab demonstrates how to build Azure networking fundamentals purely via Azure CLI, without using the Azure Portal.
It is part of my AZ-104 learning path and serves as the foundation for later projects involving NSGs, Load Balancers, VM Scale Sets and Bastion.
- Create a Resource Group
- Create an Azure Virtual Network (/16)
- Create multiple Subnets (/24)
- Deploy Virtual Machines into specific subnets
- Understand Azure IP planning and network segmentation
- Work CLI-only (no Portal)
- Azure Subscription
- Azure CLI or Azure Cloud Shell
- Basic understanding of IP addressing & CIDR
az group create \
--name rg-networking \
--location westeurope \
--output tableaz network vnet create \
--resource-group rg-networking \
--name vnet-main \
--address-prefix 10.0.0.0/16 \
--location westeurope \
--output tableWhy /16?
- Large address space for future growth (subnets, scaling, services).
- Best practice in Azure to avoid early re-addressing.
Subnet 1 - Frontend
az network vnet subnet create \
--resource-group rg-networking \
--vnet-name vnet-main \
--name subnet-frontend \
--address-prefix 10.0.1.0/24Subnet 2 - Backend
az network vnet subnet create \
--resource-group rg-networking \
--vnet-name vnet-main \
--name subnet-backend \
--address-prefix 10.0.2.0/24Why /24?
- 256 IPs per Subnet
- Azure reserves 5 -> 251 usable IPs
- Clean separation & easy scaling
az vm create \
--resource-group rg-networking \
--name vm-frontend01 \
--image Ubuntu2204 \
--size Standard_B2s \
--admin-username azureuser \
--generate-ssh-keys \
--vnet-name vnet-main \
--subnet subnet-frontend \
--public-ip-sku Standard \
--output tableaz vm create \
--resource-group rg-networking \
--name vm-backend01 \
--image Ubuntu2204 \
--size Standard_B2s \
--admin-username azureuser \
--generate-ssh-keys \
--vnet-name vnet-main \
--subnet subnet-backend \
--public-ip-sku Standard \
--output table
Note: In a real-world setup, backend VMs would not have a public IP and would only be reachable via Bastion, Load Balancer or private access. This is intentionally simplified for learning purposes.
az vm list-ip-addresses \
--resource-group rg-networking \
--output tableProof - Verify Placement
Cleanup (optional)
az group delete \
--name rg-networking \
--yes \
--no-wait-
Azure IP planning (/16 VNet + /24 subnets)
-
CLI-based network creation
-
Subnet isolation & design
-
Deploying VMs into specific subnets
-
Foundation for:
-
NSGs
-
Bastion
-
Load Balancers
-
VM Scale Sets
- Add Network Security Groups (NSG)
- Restrict traffic between subnets
- Remove public IP from backend VM
- Introduce Azure Bastion
- Combine with VMSS & Load Balancer