To decommission a virtual machine (VM) in Azure, you can follow these steps:
Stop the virtual machine: Before you can decommission a virtual machine, you need to stop it. This can be done through the Azure portal, Azure CLI, or Azure PowerShell.
Deallocate the virtual machine: After the virtual machine is stopped, you need to deallocate it. This will release the resources associated with the VM back to the resource pool.
Delete the virtual machine: Once the virtual machine is deallocated, you can delete it. Deleting the virtual machine will remove it from your Azure subscription, along with its associated disks, network interfaces, and other resources.
Note: Before deleting a virtual machine, make sure to backup any important data or configurations, as they will be lost once the virtual machine is deleted.
Here’s an example of how you can decommission a virtual machine using the Azure CLI:
# Stop the virtual machine
az vm stop –name
# Deallocate the virtual machine
az vm deallocate –name
# Delete the virtual machine
az vm delete –name
Replace