Quick and easy Azure VM creation CLI tool supporting Windows and Linux VMs.
At ToDesktop we use Azure VMs to quickly test x86-based Windows apps. It's useful for us because Apple Silicon Macs, are slow to emulate x86 VMs, so we spin up VMs in Azure instead for testing.
- 🚀 Quick VM Creation - Create VMs with a single command
- 🖥️ Multi-OS Support - Windows 11/10, Ubuntu, Debian, CentOS, and more
- 🔐 Secure Passwords - Auto-generates secure passwords meeting Azure requirements
- 📍 Smart Defaults - Sensible defaults for all parameters
- 🌍 Global Regions - Support for all Azure regions
- 💰 Cost Conscious - Includes commands to stop/delete VMs when not in use
- Azure CLI installed
- Azure account with active subscription
- Logged in to Azure CLI (
az login)
You don't need to install this tool! Use it directly with npx:
npx @todesktop/az-vmOr install globally if you prefer:
npm install -g @todesktop/az-vmCreate a Windows 11 VM with all defaults:
# Using npx (no installation required)
npx @todesktop/az-vm
# Using global install
az-vmCreate an Ubuntu VM:
# Using npx
npx @todesktop/az-vm --image=ubuntu
# Using global install
az-vm --image=ubuntu# Windows 10 in UK South
npx @todesktop/az-vm --image=windows-10 --location=uksouth
# or with global install: az-vm --image=windows-10 --location=uksouth# Ubuntu with custom name
npx @todesktop/az-vm --image=ubuntu --name=my-dev-server
# or with global install: az-vm --image=ubuntu --name=my-dev-server# Windows Server 2022 with larger size
npx @todesktop/az-vm --image=windows-server-2022 --size=Standard_D4s_v3
# Custom image URN
npx @todesktop/az-vm --image=Canonical:0001-com-ubuntu-server-jammy:22_04-lts:latest| Option | Description | Default |
|---|---|---|
--location | Azure region | northeurope |
--name | VM name | Auto-generated |
--size | VM size | Standard_D2s_v3 |
--image | OS image preset or URN | windows-11 |
--resourceGroup | Resource group name | Auto-generated |
--username | Admin username | azureuser |
--password | Admin password | Auto-generated |
--help | Show help | - |
| Preset | Description |
|---|---|
windows-11 | Windows 11 Pro (default) |
windows-10 | Windows 10 Pro |
windows-server-2022 | Windows Server 2022 Datacenter |
windows-server-2019 | Windows Server 2019 Datacenter |
ubuntu | Ubuntu 22.04 LTS |
ubuntu-20 | Ubuntu 20.04 LTS |
debian | Debian 11 |
centos | CentOS 7.9 |
rhel | Red Hat Enterprise Linux 8 |
suse | SUSE Linux Enterprise Server 15 |
| Size | vCPUs | RAM | Description |
|---|---|---|---|
Standard_D2s_v3 | 2 | 8 GB | Default, general purpose |
Standard_D4s_v3 | 4 | 16 GB | Better performance |
Standard_D8s_v3 | 8 | 32 GB | High performance |
Standard_B2s | 2 | 4 GB | Burstable, cost-effective |
Standard_B2ms | 2 | 8 GB | Burstable with more RAM |
| Location | Description |
|---|---|
northeurope | Ireland (default) |
uksouth | UK South |
westeurope | Netherlands |
eastus | Virginia |
westus | California |
Windows VMs come with Remote Desktop (RDP) enabled out of the box. Simply:
1. Open Microsoft Remote Desktop (built into Windows, available for Mac/iOS/Android)
2. Enter the provided IP address
3. Username: .\azureuser
4. Use the generated password
No additional setup required!
Linux VMs are created as servers without a GUI by default. Connect via SSH:
ssh azureuser@<ip-address>Unlike Windows VMs, Linux VMs require additional setup for remote desktop access. Here are your options:
For Ubuntu/Debian:
- Install desktop environment and VNC server:
# Update packages
sudo apt update
# Install lightweight desktop environment (XFCE) and VNC
sudo apt install xfce4 xfce4-goodies tightvncserver -y- Configure VNC:
# Start VNC server to create config files
vncserver
# You'll be prompted to create a VNC password (max 8 characters)# Kill the server after initial setup
vncserver -kill :1
# Backup and edit the startup script
mv ~/.vnc/xstartup ~/.vnc/xstartup.bak
nano ~/.vnc/xstartup- Add this content to ~/.vnc/xstartup:
#!/bin/bash
xrdb $HOME/.Xresources
startxfce4 &- Make it executable and start VNC:
chmod +x ~/.vnc/xstartup
vncserver -geometry 1920x1080 -depth 24- Open VNC port in Azure (5901):
az vm open-port --resource-group <resource-group> --name <vm-name> --port 5901- Connect from your local machine:
- Download a VNC client (RealVNC, TightVNC, or TigerVNC)
- Connect to:
<vm-ip>:5901 - Use the VNC password you created
For better performance, use X2Go instead:
# Install X2Go server
sudo apt-add-repository ppa:x2go/stable
sudo apt update
sudo apt install x2goserver x2goserver-xsession -yThen use X2Go Client on your local machine to connect.
xRDP allows you to use Windows Remote Desktop to connect to Linux:
# Install xRDP and desktop environment
sudo apt update
sudo apt install ubuntu-desktop xrdp -y
# Configure xRDP to use port 3389
sudo systemctl enable xrdp
sudo systemctl restart xrdp
# For better performance with xRDPecho"exec startxfce4">~/.xsessionThen connect using Windows Remote Desktop client to port 3389.
az vm stop --resource-group <resource-group> --name <vm-name>az vm start --resource-group <resource-group> --name <vm-name>az group delete --name <resource-group> --yes- 🕐 First connection to Windows VMs may take 2-3 minutes while Windows initializes
- 💸 Always stop or delete VMs when not in use to avoid charges
- 🔑 Save the generated password - it's only shown once
- 🌐 Choose a location close to you for better performance
- 🖥️ For Linux GUI access: xRDP works best with Windows clients, VNC with Mac/Linux
- 🚀 Use lightweight desktop environments (XFCE) for better remote desktop performance
MIT © ToDesktop
Issues and PRs welcome at github.com/todesktop/az-vm