@kyanny's blog

My thoughts, my life. Views/opinions are my own.

Azure CLI: how to create/delete ResourceGroup and VM

Create a Resource Group

az group create --name kyannyRG --location southeastasia

Delete a Resource Group

az group delete --name kyannyRG -y

Create a VM

az vm create -g kyannyRG -n kyannyVM --image UbuntuLTS --public-ip-sku Standard

Delete a VM

az vm delete -g kyannyRG -n kyannyVM -y

SSH to the VM

az ssh vm # install `az ssh` extension; only first time
az ssh vm -g kyannyRG -n kyannyVM --local-user kyanny

# OR

ssh $(az vm list-ip-addresses -g kyannyRG --query '[0].virtualMachine.network.publicIpAddresses[0].ipAddress' -o tsv)