☁️ Free VM on Azure

Setting Up a Free Tier VM on Microsoft Azure

Prerequisites

- A Microsoft account (Outlook, Hotmail, GitHub, or a work/school account)
- A phone number for verification
- A credit or debit card for identity verification (Azure requires one, even for free accounts)
- A terminal with SSH (Linux, macOS, or Windows 10+ PowerShell)

How the Azure free account works (check this first)

The Azure free account has two parts. Confirm the current terms on the Azure free account page before you start, because Microsoft changes the list of eligible services and sizes.

- Credit: about $200 to spend on anything in the first 30 days. When the 30 days end or the credit runs out, your subscription is disabled until you upgrade. Nothing is charged automatically.
- 12 months of popular free services (after you upgrade to pay-as-you-go): for Linux VMs this has included 750 hours/month of a B1s VM (or the newer B2pts v2 / B2ats v2 sizes), plus two 64 GB managed SSD disks and a small amount of outbound data (15 GB/month).
- Always-free services: a longer list of services with monthly limits that never expire.
- Upgrading to pay-as-you-go keeps the 12-month free services, but anything beyond the free amounts is billed to your card. This is where surprise charges come from, so set a budget alert first.
- In the VM size picker, look for the "Free services eligible" label or check the free services list before you choose a size. Trust that over anything written here.

Step 1: Create an Azure Account

1. Go to azure.microsoft.com/free and click "Try Azure for free"
2. Sign in with your Microsoft account
3. Enter your country, phone number, and verify by text or call
4. Add your card for identity verification
5. Accept the agreement and click Sign up
6. Open the Azure portal at portal.azure.com

Step 2: Secure the Account

1. Turn on multi-factor authentication for your Microsoft account (account.microsoft.com → Security)
2. Avoid sharing the account owner login. If others need access, add them with limited roles under Subscriptions → Access control (IAM)
3. Set a budget alert before you create anything (see "To Stay Free" below)

Step 3: Create the Free Tier VM

1. In the portal search bar, type "Virtual machines" and open it
2. Click Create → Azure virtual machine
3. Basics tab:
   - Subscription: your Free Trial subscription
   - Resource group: Create new → free-vm-rg
   - Virtual machine name: free-vm
   - Region: pick one close to you and stay in it (some regions run out of free-size capacity; try another if the size is unavailable)
   - Image: Ubuntu Server 22.04 or 24.04 LTS (or Debian 12)
   - Size: click "See all sizes" and choose a free-eligible size such as Standard_B1s, B2pts_v2 or B2ats_v2
   - Authentication type: SSH public key
   - Username: azureuser
   - SSH public key source: Generate new key pair, key pair name free-vm-key
4. Inbound port rules: Allow selected ports → SSH (22). Leave HTTP and HTTPS unchecked for now
5. Disks tab: OS disk type "Standard SSD" (or Standard HDD). A 30 GB default disk is fine. Tick "Delete with VM"
6. Networking tab: leave the defaults, tick "Delete public IP and NIC when VM is deleted"
7. Management tab: enable Auto-shutdown and set a time (optional but useful)
8. Review + create → Create
9. When prompted, click "Download private key and create resource". Save the .pem file. You cannot download it again

Step 4: Connect to Your VM

1. Protect your key file:
chmod 400 ~/Downloads/free-vm-key.pem
2. In Virtual machines → free-vm, copy the Public IP address from the Overview page
3. Connect:
ssh -i ~/Downloads/free-vm-key.pem azureuser@PUBLIC_IP
4. Or use the browser: free-vm → Connect → Connect (or Bastion; Bastion costs extra, so skip it on a free account)

The same VM from the Azure CLI (az login first):
az group create --name free-vm-rg --location eastus
az vm create --resource-group free-vm-rg --name free-vm --image Ubuntu2204 --size Standard_B1s --admin-username azureuser --generate-ssh-keys --public-ip-sku Standard

Step 5: Basic Setup

Once in the VM (Ubuntu shown):
sudo apt update && sudo apt upgrade -y
sudo apt install -y nginx  # example
sudo systemctl enable --now nginx

To serve web traffic, open the ports in the network security group (not just the OS firewall):
1. free-vm → Networking → Network settings → Create port rule → Inbound port rule
2. Destination port ranges: 80 (then repeat for 443), Protocol TCP, Action Allow
3. Set the source to Any if the site is public
4. Keep SSH (port 22) limited to your own IP: edit the SSH rule and set Source to "IP Addresses" with your address

Or from the CLI:
az vm open-port --resource-group free-vm-rg --name free-vm --port 80 --priority 900

Important Limits & Warnings

- Free hours: 750 hours/month covers one VM running 24/7. A second VM runs the meter out in half a month.
- Disks: two 64 GB managed disks are free. Extra disks and snapshots cost money.
- Data transfer: only a small amount of outbound data is free (15 GB/month at the time of writing). More is billed.
- Public IP addresses: a Standard public IP is billed by the hour on its own, and it keeps billing while it exists, even if the VM is deallocated. Confirm what is included in your free services list.
- Stopping from inside the VM (sudo shutdown) does NOT stop compute billing. Use "Stop" in the portal so the VM is Deallocated.
- Danger zones that cost money:
  - Larger or non-eligible VM sizes (anything outside the free list)
  - Azure Bastion, NAT Gateway, Load Balancer and Application Gateway
  - Premium SSDs bigger than the free allowance, and unattached disks
  - Public IPs left behind after a VM is deleted
  - Running VMs in more than one region at the same time

To Stay Free

1. Set a budget alert first: Cost Management + Billing → Cost Management → Budgets → Add → set the amount to $1 and add your email under Alert conditions
2. Watch the free service usage: Subscriptions → your subscription → Free services (shows how much of each free amount you have used)
3. Deallocate the VM when you are not using it: Virtual machines → free-vm → Stop (status must read "Stopped (deallocated)")
4. Do not upgrade to pay-as-you-go until you are ready. Leaving the free account as it is means the subscription just disables itself when the credit ends, with no bill
5. Check Cost analysis weekly so nothing hides somewhere you forgot about

Cleanup When Done

The easiest way is to delete the whole resource group, which removes the VM, disks, IP, NIC and network together:
1. Resource groups → free-vm-rg → Delete resource group → type the name to confirm
2. Or from the CLI:
az group delete --name free-vm-rg --yes --no-wait
3. Check Resource groups for leftovers such as NetworkWatcherRG (free, and safe to leave)
4. Confirm the subscription shows no charges in Cost Management the next day

Quick Verification

Check the VM state and IP from the command line (needs the Azure CLI):
az vm list --show-details --query "[].{name:name, state:powerState, ip:publicIps, size:hardwareProfile.vmSize}" --output table

List anything that could still be billing you:
az disk list --query "[].{name:name, size:diskSizeGb, state:diskState}" --output table
az network public-ip list --query "[].{name:name, ip:ipAddress, sku:sku.name}" --output table
az resource list --output table

Biggest gotchas: a VM that is stopped but not deallocated, a public IP left behind after deleting a VM, and upgrading to pay-as-you-go without a budget alert. Also, the free period ends: the $200 credit after 30 days, the 12-month services after a year. Put both dates in your calendar and delete everything before the end.

Free account terms change. Verify current limits at azure.microsoft.com/free before relying on any number in this guide.

Need help with a specific use case (web server, VPN, bot, etc.)?