Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Deploy VNETs with AZCLI
#AuthN
az login
#Create RG
az group create -n "VNET-AZCLI-RG" -l "Australia East"
#Create Hub VNET
az network vnet create -n "msft-hub-vnet" --address-prefix "10.0.0.0/16" --subnet-name "firewall" --subnet-prefix "10.0.1.0/24" --dns-servers "10.0.2.4" "10.0.2.5" "168.63.129.16" --tags department="Central IT" managedBy="Admins" -g "VNET-AZCLI-RG"
az network vnet subnet create -n "ad" --address-prefix "10.0.2.0/24" --vnet-name "msft-hub-vnet" -g "VNET-AZCLI-RG"
az network vnet subnet create -n "mgmt" --address-prefix "10.0.3.0/24" --vnet-name "msft-hub-vnet" -g "VNET-AZCLI-RG"
az network vnet subnet create -n "GatewaySubnet" --address-prefix "10.0.0.0/27" --vnet-name "msft-hub-vnet" -g "VNET-AZCLI-RG"
#Create Spoke VNET
az network vnet create -n "msft-spoke1-vnet" --address-prefix "10.1.0.0/16" --subnet-name "web" --subnet-prefix "10.1.1.0/24" --dns-servers "10.0.2.4" "10.0.2.5" "168.63.129.16" --tags department="HR" managedBy="DevOps" -g "VNET-AZCLI-RG"
az network vnet subnet create -n "biz" --address-prefix "10.1.2.0/24" --vnet-name "msft-spoke1-vnet" -g "VNET-AZCLI-RG"
az network vnet subnet create -n "data" --address-prefix "10.1.3.0/24" --vnet-name "msft-spoke1-vnet" -g "VNET-AZCLI-RG"
#Create VNET Peerings
az network vnet peering create -g VNET-AZCLI-RG -n msft-hub-vnet-to-msft-spoke1-vnet --vnet-name msft-hub-vnet --remote-vnet msft-spoke1-vnet --allow-vnet-access --allow-forwarded-traffic --allow-gateway-transit
az network vnet peering create -g VNET-AZCLI-RG -n msft-spoke1-vnet-to-msft-hub-vnet --vnet-name msft-spoke1-vnet --remote-vnet msft-hub-vnet --allow-vnet-access --allow-forwarded-traffic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.