How to create a virtual machine in Azure
With the Azure CLI, you can use the az vm create
command to create a virtual machine
RESOURCE_GROUP="myResourceGroup"
LOCATION=eastus
VM_NAME=myVM
VM_IMAGE=Ubuntu2204
VM_SIZE=Standard_B1s
VM_ADMIN_USERNAME=username
VM_ADMIN_PASSWORD=Password@000
az vm create \
--resource-group $RESOURCE_GROUP \
--name $VM_NAME \
--image $VM_IMAGE \
--size $VM_SIZE \
--admin-username $VM_ADMIN_USERNAME \
--admin-password $VM_ADMIN_PASSWORD
And this will be the result if everything goes right
{
"fqdns": "",
"id": "/subscriptions/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM",
"location": "eastus",
"macAddress": "00-00-00-00-00-00",
"powerState": "VM running",
"privateIpAddress": "10.0.0.4",
"publicIpAddress": "40.50.60.70",
"resourceGroup": "myResourceGroup",
"zones": ""
}
For more details, click on the link below to access the official documentation
Member discussion