Delete Azure Virtual Machine With Azure CLI

In this Microsoft Azure blog post we are going to delete a Virtual Machine running using the Azure CLI command line utility.

Azure CLI

The Azure CLI command-line utility allows us to manage most of the Azure services programmatically without using the portal.

To get started, login to Azure and authenticate using the following command.

az login --use-device-code

Set your your Azure subscription if you have more than one.

az account set --subscription subscription-name

In the example below, I’m deleting a Virtual machine called mailtrainvm located inside a resource group called mailtran.

The command will not ask for confirmation and force the delete the virtual machine.

az vm delete --resource-group mailtrain --name mailtrainvm --yes --force-deletion yes

Processing…
Success! You're on the list.

Leave a comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.