Power states
Azure VM (virtual machines) have various power states available which are related to each VM’s lifecycle. The Azure VM power states are the following:
- Starting: The VM is being started.
- Running: The VM is running.
- Stopping: The VM is being stopped.
- Stopped: The VM is stopped. Note that VMs in the stopped state still incur compute charges.
- Deallocating: The VM is being deallocated.
- Deallocated: The VM is completely removed from the hypervisor but still available in the control plane. VMs in the deallocated state do not incur compute charges.
- Unknown (
-
): The power state of the VM is unknown.
A common confusion comes in when comparing the power status of stopped vs stopped (deallocated). A good explanation of the difference between the two is provided in the following Microsoft article: https://docs.microsoft.com/en-us/archive/blogs/gbanin/difference-between-the-states-of-azure-virtual-machines-stopped-and-stopped-deallocated
Provisioning states
Azure VMs also have provisioning states. A provisioning state is the status of a user-initiated, control-plane operation on the VM. These states are separate from the power state of a VM.
- Create – VM creation.
- Update – updates the model for an existing VM. Some non-model changes to VM such as Start/Restart also fall under update.
- Delete – VM deletion.
- Deallocate – is where a VM is stopped and removed from the host. Deallocating a VM is considered an update, so it will display provisioning states related to updating.
How to view the power states and provisioning states
The instance view API provides VM running-state information. For more information, see the Virtual Machines – Instance View API documentation. Azure Resources explorer provides a simple UI for viewing the VM running state: Resource Explorer. Provisioning states are visible on VM properties and instance view. Power states are available in instance view of VM.
To retrieve the state of a virtual machine by Powershell, the below cmdlet can be used:
Get-AzureRmVM -ResourceGroupName "TestResourceGroupName" -Name "VMName" -Status
.NET API reference
The .NET API for Azure management has the following class whose methods can be called to retrieve and manage data related to Azure VM power states and provisioning states.
Namespace: Microsoft.Azure.Management.Compute.Fluent Assembly:Microsoft.Azure.Management.Compute.Fluent.dll Package:Microsoft.Azure.Management.Compute.Fluent v1.33.0
Sources
https://docs.microsoft.com/en-us/azure/virtual-machines/windows/states-lifecycle