Create a Microsoft Azure virtual machine
This topic describes how to create a Microsoft Azure virtual machine (VM) using the command line. You can't create the VM using the Microsoft Azure Portal.
Before you begin
Run the az disk revoke-access command before you create the disk. If you don't run this command, the disk isn't available and the VM command may time out or fail.
Start this procedure
-
Run the
az disk listcommand to list the details of available disks.az disk list --resource-group <resource-group><resource-group>: The name of the previously created resource group.Here's an example of the
az disk listcommand with the parameter populated with a value:az disk list --resource-group AccessGatewayWhen you run the
az disk listcommand, the following results appear:{ . . . "encryptionSettingsCollection": null,"hyperVgeneration": "V1", "id": "/subscriptions/8bc.../resourceGroups/AccessGateway. . ./disks/AG2020-05-00", "location": "eastus", . . . } - Create a VM using the
az vm createcommand:az vm create --resource-group <resource-group> --location <region>> \\ --size <size of VM> \\ --name <name-of-VM> --os-type linux --attach-os-disk <virtual-disk>-
<region>: The region to hold the VM. -
<size>: The SKU of the size of the VM. Run this command for a list of size SKUs:az vm list-skus --location <region> --output table -
<name-of-vm>: The name of the VM. -
<virtual-disk>: The name of the virtual disk to associate with the VM. -
<resource-group>: The name of the previously created resource group to house the VM.
Here's an example of the
az vm createcommand with the parameters populated with values:az vm create --resource-group AccessGateway --location eastus \ --name AccessGateway --os-type linux \ --attach-os-disk AccessGatewayDisk --size Standard_D2s_v3When you run the
az vm createcommand, the following results appear:{- Finished .. "fqdns": "", "id": "/subscriptions/508555fa. . . /resourceGroups/AccessGateway/providers/Microsoft.Compute/virtualMachines/OAG5.0VM", "location": "eastus", "macAddress": "00-0D-3A-0E-9C-C1", "powerState": "VM running", "privateIpAddress": "10.0.0.5", "publicIpAddress": "52.167.120.101", "resourceGroup": "AccessGateway", "zones": "" } -
Next steps