Use Azure CLI to create a virtual machine, azurecli
Use the az vm create command to create a vm.
When creating a virtual machine, you can use multiple options, such as operating system image, disk size adjustment, and credential management. In this example, a virtual machine running Ubuntu Server named "myVM" is created.
Az vm create -- resource-group myResourceGroupVM -- name myVM -- image snapshot tults -- generate-ssh-keys
After a VM is created, Azure CLI outputs information about the VM. Please note downPublicIpAddress
You can use this address to access the virtual machine.
{"Fqdns": "", "id": "/subscriptions/d5b9d4b7-6fc1-0000-0000-000000000000/resourceGroups/myResourceGroupVM/providers/Microsoft. compute/virtualMachines/myVM "," location ":" chinaeast "," macAddress ":" 00-0D-3A-23-9A-49 "," powerState ":" VM running "," privateIpAddress ":" 10.0.0.4 ", "publicIpAddress": "52.174.34.95", "resourceGroup": "myResourceGroupVM "}
Connect to VM
Now you can use SSH to connect to the VM. Replace the sample IP address withPublicIpAddress
.
Ssh 52.174.34.95
After using the VM, close the SSH session.
Exit
For more information about the VM image and size, click here.