What Is an Azure VM?
An Azure Virtual Machine (Azure VM) is a scalable, on-demand computing resource offered in the Microsoft Azure cloud. You would usually choose VMs when you need more control over the cloud computing environment.
Azure VMs provide virtualization, allowing you to use resources without buying or maintaining the physical infrastructure required to run them. You maintain your VMs by performing configuration, patching, and software installation tasks.
There are several ways to use Azure virtual machines. For example, they provide a fast, easy way to build a dev/test environment in the cloud. Azure VMs are also suitable for cloud-hosted applications with fluctuating demands—this makes more sense economically because you don’t have to pay for additional hardware when you’re not using it.
Finally, you can use Azure VMs to extend your data center by connecting them to the on-premises corporate network. You can scale the number of VMs your applications use to meet your workload requirements.
This is part of a series of articles about Azure cost.
In this article:
Azure VM Pricing Basics
Pricing for Azure Virtual Machines is based on several factors. The first is the VM instance type (known as SKU). Azure offers hundreds of VM instance types, each with a different price. Each instance type has different memory, vCPU, and temporary storage resources, and some with GPUs, each a different price.
Other pricing factors include the period of time a VM runs, usually measured in minutes, the pricing model selected (on-demand, reserved instance, spot VM, etc.), and the Azure region in which the instance runs.
Beyond the basic VM price, Azure charges extra for data transfer outside Azure or to another Azure region, load balancing, managed disks that offer persistent storage, and other services.
5 Azure VM Pricing Models
Azure VMs are available in five pricing models with different benefits.
1. Free Tier
Azure offers several free plans.
- Free Azure account for a limited time – Azure offers a free trial to attract potential customers, providing a free tier with $200 of Azure credits for 30 days and limited free services for up to 12 months. You can set up free services in any Azure region and create multiple instances if you stay within the free plan’s limits.
- Services that are always free – in addition to the free account, Azure offers always-free services for Azure account holders, available on the free services page in the Azure portal.
- Development and testing pricing – Azure offers Azure Dev/Test discounts and monthly credits for Visual Studio.
2. Pay-as-You-Go Model
The simplest way to spin up Azure VMs is to pay as you go. Microsoft charges for the time the VMs are active (calculated in seconds). This option is the most flexible, suitable for short workloads and instances that don’t tolerate interruptions. There is no upfront payment or long-term commitment, but VM prices are typically high.
This model lets you easily scale the compute capacity up or down based on the application’s demands.
3. Reserved Instance Model
Reserving VM instances can help save money when you know the VMs will be active for a year or more. Reserved instances are tied to specific regions for a one or three-year term, but you can also return or exchange them. Canceling instances incurs early termination fees.
Typically, you might use reserved instances for applications with steady-state usage or reserved capacity requirements.
4. Spot Instance Model
Another way to save money is Spot VM instances—although these are only suitable if you can tolerate downtime and availability issues. Spot pricing can provide a 90% discount because you pay for Azure’s unused capacity. Azure can evict or shut down Spot VMs when it needs the capacity again. Also, the price for Spot instances can change.
This model is useful for ephemeral and test workloads, not production, as it doesn’t provide SLAs.
5. Azure Hybrid Model
Due to operating system licenses, Azure Linux VMs are usually cheaper than Windows Azure VMs. Windows requires a license to run, which adds to the cost of Azure VMs. You can reduce your Azure VM costs if you already have Windows licenses for on-prem servers.
Migrating existing workloads from Windows Server, Server 2008 R2, or SQL Server 2008 can add three years of free security updates.
Best Practices for Optimizing Azure VM Costs
When selecting VMs in Azure, some best practices can help you optimize cost without sacrificing performance.
Consider B-series Virtual Machines
A major problem with cost management in Azure is that many workloads have inconsistent usage, leading to instances that are sometimes under utilized. This is a problem because the system is charged as long as the VM is active, whether or not the VM is fully in use.
One possible solution is to use a B series or bustable machines. These systems are always available, but are designed for inconsistent workloads. They can provide a burst of CPU power when needed to support higher loads. With a B-series machine, you can get 15-55% off similar D-series machines.
Find the Right Resource Size
Properly sizing resources minimizes waste, which can significantly reduce costs. When sizing properly, you should choose resources that are as close as possible to your workload requirements.
If your workload is mission critical, you should provision slightly more resources than your expected maximum requirements. However, if a workload can tolerate some delay, you can provision less resources.
If you’re not sure how to size, you can use a cloud optimization tool to determine the optimal number. These tools monitor your workload and provide feedback and recommendations based on a typical usage period.
You can also use metrics available through the Azure portal. Pay particular attention to the Memory Percentage and CPU Percentage stats. If these statistics are consistently below 50%, you can probably reduce the size of your system with minimal performance impact.
Use Spot VMs
By integrating Spot VMs into your deployment for appropriate use cases, you can save money without impacting mission-critical workloads.
You should consider using spot VMs especially for batch processing – these are processes that often have no time constraints and can run in the background or overnight. Spot VMs can also be used in development and test environments. In these cases, you don’t have to worry too much about service level agreements or long-term performance.