This document guides you through the process of deleting a virtual machine (VM) in Azure. Deleting a VM is a permanent action and cannot be undone. All associated resources, such as disks and network interfaces, may also be deleted depending on your configuration.
You can delete a virtual machine using the Azure portal, Azure CLI, or Azure PowerShell.
The Azure portal provides a user-friendly graphical interface to manage your Azure resources.
The Azure Command-Line Interface (CLI) is a powerful tool for managing Azure resources from your terminal.
First, ensure you are logged in to your Azure account:
az login
Then, use the az vm delete command. Replace <resource-group-name> with the name of the resource group containing your VM, and <vm-name> with the name of your virtual machine.
az vm delete --resource-group <resource-group-name> --name <vm-name> --yes
The --yes flag automatically confirms the deletion without prompting.
To delete the VM and its associated resources (like disks), you might need to use additional commands or parameters depending on how the VM was created and configured.
Azure PowerShell provides cmdlets for managing Azure resources.
First, ensure you are logged in to your Azure account:
Connect-AzAccount
Then, use the Remove-AzVM cmdlet. Replace <resource-group-name> with the name of the resource group, and <vm-name> with the name of your virtual machine.
Remove-AzVM -ResourceGroupName <resource-group-name> -Name <vm-name> -Force
The -Force parameter automatically confirms the deletion.
Similar to the CLI, managing associated resources might require additional cmdlets like Remove-AzDisk or Remove-AzPublicIpAddress.
Once a VM is deleted, it will no longer appear in your Azure portal or be accessible. You will stop being billed for the VM's compute resources. However, you may continue to be billed for associated storage resources (like unattached disks) if they were not deleted.