There are 2 ways to shutdown an Azure VM, and they are certainly not equal! One way you will still get charged for the compute resources, and the other will free you from paying for the compute resources and help you reduce overall cost.

The first method to shutdown an Azure VM, that sounds logical in the context of connecting with Remote Desktop, is to Shutdown the Operating System. In this scenario you would be connected with Remote Desktop, and when done with your work you go to the Power options within Windows and select Shutdown. This will essentially “turn off” the VM and stop it from running. However, even though the VM won’t be running you WILL still be paying for the Virtual machine hardware allocation. Doing this will cause the Azure Portal to report the status of the VM to be “Stopped”.

The second method, and the one to remember, is to go into the Azure Portal (or use Azure PowerShell or Azure CLI) and Stop the VM. Instead of just shutting down the Operating System, Azure will also deallocate the hardware (CPU and Memory) allocation; thus releasing it to be used for another workload in Microsoft Azure. Doing this will cause the Azure Portal to report the status of the VM to be “Stopped (Deallocated)”.

It’s a good idea that when ever you don’t actually need the VM to be running that you Stop it using the Azure Portal, PowerShell, or Azure CLI so that the resources are released. While in the “Stopped (Deallocated” status, you will not be paying for the VM resources. This will really help you save money!

Manually Shutdown

To “properly” Stop a VM in the Azure Portal to release the resources and save money, you can follow these steps:

  1. Within the Azure Portal, navigate to the Virtual Machine blade for the desired VM.
  2. On the Overview pane, click the Stop button.

There is one caveat to be aware of when shutting down an Azure VM so it gets placed into the Stopped (Deallocated) status. Since this causes Azure to release the server resources associated with the Virtual Machine, it not only releases the CPU and Memory resources but also the Dynamic IP Address allocation. Due to this, when you Start the VM back up again, the IP Address will likely change. If you require the IP Address to never change for your VM, then you’ll need to configure a Static IP Address for the VM.

To start up a Stopped VM, you can follow these steps:

  1. Within the Azure Portal, navigate to the Virtual Machine blade for the desired VM.
  2. On the Overview pane, click the Start button.

Another point that’s important to remember when stopping Azure VM’s and placing them into the “Stopped (Deallocated)” state is that you do still pay for the Azure Storage account usage. Remember, the Storage account is where the VM’s .vhd disk image file is stored. Stopping the VM retains all the VM’s settings / configurations, as well as the .vhd image stored in Azure Storage. As a result, you will still incur some cost for the storage, but at least you will save on the VM resources. After all, the Storage will only cost a small amount of money compared to the much higher cost of the Virtual Machine resource allocation if it were left running constantly.

Sources:

https://buildazure.com/2017/03/16/properly-shutdown-azure-vm-to-save-money/

Last modified: May 10, 2019

Author

Comments

Write a Reply or Comment