Creating an Ubuntu vm in Azure




Azure cli 2.0




# Resource group.
az group create --name myResourceGroup --location westus
# Virtual network.
az network vnet create --resource-group myResourceGroup --name myVnet --subnet-name mySubnet
# Pub IP address.
az network public-ip create --resource-group myResourceGroup --name myPublicIP
# Network security group.
az network nsg create --resource-group myResourceGroup --name myNetworkSecurityGroup
# Virtual NIC and IP and NSG.
az network nic create \
  --resource-group myResourceGroup \
  --name myNic \
  --vnet-name myVnet \
  --subnet mySubnet \
  --network-security-group myNetworkSecurityGroup \
  --public-ip-address myPublicIP
# New vm with SSH keys
az vm create --resource-group myResourceGroup --name myVM --nics myNic --image UbuntuLTS --generate-ssh-keys
 # Open port 22 to allow SSh traffic to host.
az vm open-port --port 22 --resource-group myResourceGroup --name myVM
Was this article helpful?
0 out of 0 found this helpful

Have more questions? Contact our support instantly via Live Chat