Skip to content

Instantly share code, notes, and snippets.

@rezamt
Last active March 9, 2018 12:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rezamt/0f88413c9d77e45f8eec1386e5b3a9e4 to your computer and use it in GitHub Desktop.
Save rezamt/0f88413c9d77e45f8eec1386e5b3a9e4 to your computer and use it in GitHub Desktop.
azure cli
# resource group
az group create -n "rg-demo" --location "Australia Southeast" --no-wait
# ======================== Network
# nsg
az network nsg create -n "nsg-demo" -g "rg-demo" -l "Australia Southeast"
# nsg rule
az network nsg rule create -n "in-default" -g "rg-demo" --nsg-name "nsg-demo" --priority 100 --access Allow --description "Open to All internet world" --direction Inbound --protocol '*' --destination-address-prefixes '*' --destination-port-ranges '*' --source-address-prefixes '*' --source-port-ranges '*' --verbose
az network nsg rule create -n "out-default" -g "rg-demo" --nsg-name "nsg-demo" --priority 200 --access Allow --description "Open to All internet world" --direction Outbound --protocol '*' --destination-address-prefixes '*' --destination-port-ranges '*' --source-address-prefixes '*' --source-port-ranges '*' --verbose
# vnet 10.0.0.0/16
az network vnet create -n "vnet-demo" -g "rg-demo" --address-prefixes "10.0.0.0/16" -l "Australia Southeast"
# subnet 1 10.0.1.0/16 frontend
az network vnet subnet create --vnet-name "vnet-demo" -g "rg-demo" -n frontend --address-prefix 10.0.1.0/24 --network-security-group "nsg-demo"
# subnet 2 10.0.2.0/16 backend
az network vnet subnet create --vnet-name "vnet-demo" -g "rg-demo" -n backend --address-prefix 10.0.2.0/24 --network-security-group "nsg-demo"
az network vnet subnet list --vnet-name "vnet-demo" --resource-group "rg-demo"
# Frontend Subnet
# pip 01
az network public-ip create --name "pip-01" --resource-group "rg-demo" --allocation-method Dynamic --version IPv4
# pip 02
az network public-ip create --name "pip-02" --resource-group "rg-demo" --allocation-method Dynamic --version IPv4
# nic 01
az network nic create --name "nic-01" --resource-group "rg-demo" --subnet "frontend" --vnet-name "vnet-demo" --public-ip-address "pip-01"
# nic 02
az network nic create --name "nic-02" --resource-group "rg-demo" --subnet "frontend" --vnet-name "vnet-demo" --public-ip-address "pip-02"
# ============================ Compute
# vm 01
az vm create --name "vm001" \
--resource-group "rg-demo" \
--authentication-type ssh \
--generate-ssh-keys \
--image OpenLogic:CentOS:7-CI:latest \
--location "Australia Southeast" \
--nics "nic-01" \
--no-wait
# Note: When specifying an existing NIC, do not specify NSG, public IP, ASGs, VNet or subnet.
# vm 02
az vm create --name "vm002" \
--resource-group "rg-demo" \
--authentication-type ssh \
--generate-ssh-keys \
--image OpenLogic:CentOS:7-CI:latest \
--location "Australia Southeast" \
--nics "nic-02" \
--no-wait
ssh <vm01 public IP>
ssh <vm02 public IP>
# All Good and they can ping each other.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment