How To Save Money On Azure VM

Feb 13, 2024, by Rovshan Mirza

I like using Azure Windows VMs for some side projects or remote gigs, because I want to separate my personal and work/project accounts, including emails and machine IP addresses. But after running decently sized VMs (CPU and memory-wise) mostly for web browsing and using office apps, I noticed that they are costing a hefty price.

For example, I was paying $40/month per VM with 2 CPUs and 4GB RAM, which I used for 10-15 hours a week and kept it deallocated other times. I could rent much cheaper VMs for about $15/month from other cloud providers, like Contabo, and not worry about deallocating at all. But, I wanted to use Windows 10 or 11, not Windows Server 2016-2022, which Contabo or others offer.

So, I found out that there are ways you can substantially cut down expenses while using Azure VM resources.

1. Use Spot VMs

One way is to use Spot Virtual Machines instead of Pay As You Go instances. This will drastically decrease the costs. Basically, Azure lets you use the VM at the lowest rate until someone bids higher for the resource and it gets terminated, which usually never happens. Even then, you will only lose a little bit of data and you can just start it manually again. And, don't worry if you already created a regular VM, I will have a guide on how to convert it to a Spot VM soon here.

2. Shrink OS Disk Size

Another way is to shrink OS disk size of your VMs, which will save you a lot on storage expenses. When you first create your VM, the minimum OS disk size you can choose is 128GB. You can shrink it to 64GB or even 32GB, like I did, by using a PowerShell script. I'm not using much disk space on my VMs, so 32GB is plenty for me.

There is an excellent guide by Jack Rudlin showing how to shrink Azure VM's OS Managed Disk using Powershell.

3. Change Premium SSD to Standard SSD Disk Type

If you are using Premium SSD disk type on your VMs, you can save some money by changing storage type to Standard SSD. Personally, I didn't see a noticible difference in performance between these after I shrunk OS disk to 32GB. To do this, you can go to Disks > OS Disk > Size + Performance > Storage type in the portal.

After making these changes, I'm paying about $8/month per VM instead of $40. Not bad! Of course, I have to stop and deallocate the VMs after using them, but I'm using Windows 10/11 Pro, which is perfect for my needs.

Soon, I will add a guide on how to create 1) a desktop shortcut to automatically start Windows VM in Azure and connect to it using RDP, and 2) a desktop shortcut to automatically stop the VM and deallocate it without doing it from the portal or CLI manually. So, stay tuned!