Create a small Linux VM

Azure Portal, Hands On15 minutesFree tierSteps checked 28 October 2026By Cloud Hands On

In this task you'll create a virtual machine.

A virtual machine (VM) is your own server in Azure. You choose the operating system and the size, and Azure runs it in one of its datacentres. It's the most flexible compute option, and also the one you have to look after most: updates, security and backups are your job.

Creating one VM also creates the things it needs: a network card, a disk, a virtual network, a network security group and usually a public IP address. All of them go into the resource group you pick.

Example. Larkfield Group runs an old reporting tool that only works on a full Linux server, so it moves the tool to a small Azure VM in rg-reports-prod rather than rewriting it.

Before you start

You need: Contributor on the resource group. Time: 15 minutes.

Where to look

  1. Home
  2. Virtual machines
  3. + Create
  4. Azure virtual machine

Steps

  1. Search Virtual machines. It opens Compute infrastructure: if you land on its Get started page, select Virtual machines under Infrastructure in the left menu. Then select + Create, then Azure virtual machine.The form may open as a preview of a new design, with a link at the top to the previous experience. It may also suggest Windows Server and a region such as East US: you change both below.
  2. Choose rg-portal-practice as the resource group and name the VM vm-practice. Pick a region near you.
  3. Under Image, choose a current Ubuntu Server LTS version.
  4. Under Size, select See all sizes. Sizes are grouped by series with a monthly price; type B1s in the search box and pick it.On a free account, B1s runs for up to 750 hours a month free for the first 12 months. That's one VM running all month, or two for half a month. The list doesn't mark which sizes are free. If B1s shows Size not available, or creating is refused with a capacity message, pick B2ats v2 instead (also free-eligible), or try another region such as Sweden Central.
  5. Set Authentication type to SSH public key, keep the username azureuser, and let Azure generate a new key pair.
  6. Under Inbound port rules, allow SSH (22) for this practice.The portal warns that this opens the VM to the internet. It's acceptable for a short test that you delete afterwards, never for a real server.
  7. On the Disks tab, check the OS disk type. Free services cover a limited amount of Premium SSD storage, so keep the default size.
  8. Select Review + create, read the price shown, then Create. When asked, select Download private key and create resource and keep the .pem file safe.The private key is offered only once. Without it you can't sign in with SSH.

Commands

# Create a small Ubuntu VM with a new SSH key pair (saved in ~/.ssh)
az vm create --resource-group rg-portal-practice --name vm-practice \
  --image Ubuntu2404 --size Standard_B1s \
  --admin-username azureuser --generate-ssh-keys
# If B1s is refused for capacity, try --size Standard_B2ats_v2 or another --location

# Clean up: delete the group and everything in it
az group delete --name rg-portal-practice --yes

Watch out for

Cost
Within the free allowance, a B1s VM costs nothing, but the free hours are shared by all your free-eligible VMs, and a public IP address and outbound data can add small charges. Check Cost analysis the next day.
Security
Port 22 open to the whole internet attracts constant login attempts. In real use, limit SSH to known addresses, or use Azure Bastion instead of a public IP.
Common mistakes
Picking a size that isn't free-eligible. Losing the private key. Thinking that shutting the VM down from inside Linux stops the charges: only Stop in the portal does that (see the stop task).

Clean up

  1. Resource groups
  2. rg-portal-practice
  3. Delete resource group

Keep the VM for the next tasks in this section, then delete the whole resource group. That removes the VM, its disk, network card, public IP and network in one go.

Words to know

VM size
How much processor power and memory the VM gets, such as B1s (1 vCPU, 1 GB). Bigger sizes cost more per hour.
Image
The starting copy of the operating system, such as Ubuntu Server.
SSH key pair
Two matching files used to sign in to Linux instead of a password. You keep the private key secret.

Tick off each step and track your progress in the guide.

Open this task in Azure Portal, Hands On

Keep going