<link href="https://fonts.googleapis.com/css?family=Roboto:100,100italic,200,200italic,300,300italic,400,400italic,500,500italic,600,600italic,700,700italic,800,800italic,900,900italic&amp;display=swap" rel="stylesheet"/>
1 minute reading time (174 words)

Create Virtual Network and subnet using Azure CLI

How to create a Virtual Network and subnet using Azure CLI

Create resource group using az group create

# Define resource group variables for name and location 
rgName=prod-ukw-core-rg
rgLocation=ukwest 

# Create resource group and output results in a table 
az group create --name $rgName --location $rgLocation --output table
 

Create virtual network and subnet using az network vnet create

This example will create a VNet with an address space of 192.168.2.0/24 and a subnet of 192.168.2.0/27, which will allow 27 usable IP addresses.

# Define vnet variables
VnetName=prod-ukw-core-vnet
RgName=prod-ukw-core-rg
SubnetName=subnet01
AddressPrefix=192.168.2.0/24
SubnetPrefix=192.168.2.0/27

az network vnet create \
  --name $VnetName \
  --resource-group $RgName \
  --subnet-name $SubnetName \
  --address-prefix $AddressPrefix \
  --subnet-prefix $SubnetPrefix 

Related Posts

 

Comments

No comments made yet. Be the first to submit a comment
Already Registered? Login Here
Saturday, 13 September 2025
You can help support this website by buying me a coffee!
Buy Me A Coffee