Thursday, June 17, 2021

Am I billed for an Azure Virtual Machine if it's shut down?

Come to the cloud, it has consumption-based billing! But what does that mean, exactly? Is my virtual machine free if it is shut down? Lets explore the billing components of an Azure Virtual Machine.

 

Resources in Azure all have particular cost meters and charging methods. Each product page details what those are. For consumption-based billing, you need to broaden your perception of what the word "consumption" means. You might think you're not consuming the services of a virtual machine if it is shut down, but it is a little more comprehensive than that.

 

Azure Virtual Machine components

When you create a Windows Virtual Machine in Azure, you don't get just one resource. An Azure VM relies on 5 resources, created by default:

  • Virtual machine
  • Disk
  • Network interface
  • Virtual network (or choose to use an existing virtual network)
  • Network security group (optional but highly recommended)

If you want to make this VM publicly available over the internet, you also need a Public IP address.

 

Azure Virtual Machine resourcesAzure Virtual Machine resources

Now lets look at which of those components have billing implications when the VM is shut down.

 

The virtual machine resource - power states and billing

The state of the virtual machine impacts whether the virtual machine resource is being billed or not, in relation to the virtual machine resource and its reliance and use of underlying hardware.

 

Running - The virtual machine is powered up and working, and currently being billed for.

 

Stopped - The VM has been shut down from within the guest operating system or using PowerOff APIs. The VM will be showing as Stopped. This does not release the lease that the VM has on the underlying hardware, which means the hardware is unavailable for other customers. In this state, the virtual machine is still billed for.

 

Deallocated - The VM has released the lease on the underlying hardware and is completely powered off, so the virtual machine resource is not billed. It will appear in the Azure portal as Stopped (Deallocated).

 

Azure Virtual Machine statusAzure Virtual Machine status

 

What if I have the VM scheduled to shut down automatically on a schedule?

The shutdown automation provided natively by Azure puts the machine in the Deallocated state, so it is not being billed while it is shut down. See Start/stop VMs during off-hours overview.

 

What if I shut the VM down using PowerShell?

The Stop-AzVM PowerShell cmdlet also puts the machine in the Deallocated state, so it is not being billed while it is shut down.

 

What if I shut the VM down using the Azure CLI or Cloud Shell?
It depends on which command you use. az vm stop will not deallocate the VM from the hardware and will display the warning "About to power off the specified VM... It will continue to be billed. To deallocate a VM, run: az vm deallocate"

 

For more information, see States and billing of Azure Virtual Machines.

Billing of other Azure Virtual machine components

Even if the virtual machine is deallocated and not consuming "compute" time (holding a lease on hardware), there are components of this virtual machine that you are still using. Most commonly, this is storage and networking.

 

Storage - disk costs

While the VM is shut down, there is still a storage cost for the disk that is holding the virtual hard drive file, as well as any other data storage disks you may have created, as you are still consuming file storage.

 

This resource group contains a VM that was shut down for the month of May and incurred a USD$0.31 daily cost for a 127GiB Premium SSD disk with locally redundant storage including a less than USD$0.01 charge for the storage account.

 

Deallocated virtual machine costsDeallocated virtual machine costs

 

See Managed Disks pricing. 

 

Note: There's another type of storage for Azure VM operating systems called Ephemeral OS Disks. These are free and suitable for stateless workloads, but don't support features like Azure Backup, Azure Disk Encryption, Disk snapshots or Azure Site Recovery. Learn more at Ephemeral OS disks for Azure VMs.

Networking

The network interface, virtual network and network security group will not incur any charges. Visit Virtual Network pricing.

A static Public IP address will still be billed if the VM is shut down or even deleted, unless you delete the static public IP address. For pricing, visit IP Addresses pricing.


Azure Bastion (optional)

Azure Bastion allows for secure remote access to your virtual machine guest operating system via a browser, without needing to open RDP port 3389. Regardless of the state of your virtual machine, you will be charged for any Azure Bastion hosts. If you use this infrequently, you can delete and recreate an Azure Bastion host when needed. Learn more about Azure Bastion pricing here.


Other related Azure services

Other services related to Azure Virtual Machines may also incur a cost while a VM is shut down, including Azure Defender for Servers and Azure Backup.  Both Azure Arc enabled servers and Azure Lighthouse, for server management, are free capabilities.


Learn more at Microsoft Learn

Control Azure spending and manage bills with Azure Cost Management + Billing

Introduction to Azure virtual machines

 

Posted at https://sl.advdat.com/3q4NOzS