Create a Windows virtual machine with the Azure
- Maryam Ziaee
- Feb 26
- 2 min read
Create virtual machine
Create a VM with az vm create. The following example creates a VM named myVM. This example uses azureuser for an administrative user name. Replace the values of the variables as needed.
You'll be prompted to supply a password that meets the password requirements for Azure VMs.
Using the example below, you'll be prompted to enter a password at the command line. You could also add the --admin-password parameter with a value for your password. The user name and password will be used when you connect to the VM.
vmname="myVM"
username="azureuser"
az vm create \
--resource-group $resourcegroup \
--name $vmname \
--image Win2022AzureEditionCore \
--public-ip-sku Standard \
--admin-username $username
It takes a few minutes to create the VM and supporting resources. The following example output shows the VM create operation was successful.
OutputCopy
{
"fqdns": "",
"id": "/subscriptions/<guid>/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM",
"location": "westus3",
"macAddress": "00-0D-3A-23-9A-49",
"powerState": "VM running",
"privateIpAddress": "10.0.0.4",
"publicIpAddress": "52.174.34.95",
"resourceGroup": "myResourceGroupCLI"
"zones": ""
}
Take a note your own publicIpAddress in the output when you create your VM. This IP address is used to access the VM later in this article.
Cost information isn't presented during the virtual machine creation process for CLI like it is for the Azure portal. If you want to learn more about how cost works for virtual machines, see the Cost optimization Overview page.
It takes a few minutes to create the VM and supporting resources. The following example output shows the VM create operation was successful.
OutputCopy
{
"fqdns": "",
"id": "/subscriptions/<guid>/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM",
"location": "westus3",
"macAddress": "00-0D-3A-23-9A-49",
"powerState": "VM running",
"privateIpAddress": "10.0.0.4",
"publicIpAddress": "52.174.34.95",
"resourceGroup": "myResourceGroupCLI"
"zones": ""
}
Take a note your own publicIpAddress in the output when you create your VM. This IP address is used to access the VM later in this article.
Cost information isn't presented during the virtual machine creation process for CLI like it is for the Azure portal. If you want to learn more about how cost works for virtual machines, see the Cost optimization Overview page.
Install Azure CLI on Windows
Choose an installation method
WinGet (Windows Package Manager)
Microsoft Installer (MSI)Microsoft Installer (MSI) with PowerShellZIP Package



Comments