onsdag, maj 29, 2013

How to delete a VM in Windows Azure and not incur any charges

When you want to delete a Virtual Machine and make it not incur any charges to your credit card anymore there are a couple of steps that you need to go thru.

Short story

  1. Delete the Virtual Machine
  2. Wait until the disk is detached from the Virtual Machine
  3. Delete the disk and delete the associated VHD
  4. Delete the Cloud Service
  5. Delete the Storage Account

Long Story

First of all you need to delete the Virtual Machine. This is the easy part and many think that this is enough. One thing that might be confusing is that when you delete a Virtual Machine a Cloud Service appears!

Look at the picture below. It has one VM deployed and zero Cloud Services. This will change when we delete the VM.Now click on Delete at the bottom of the screen with the Virtual Machine selected.

DeleteVM1

Deleting the VM takes a couple of seconds and after this is done you see that you have 0 Virtual Machines but 1 Cloud Service. Where did that come from?

DeleteVM2

If you now click on the Cloud Service link you will see that the Cloud Service you have has the same name as the VM that you used to have. So this is just a trick that we do in the portal to not confuse you but the effect when you delete is somewhat confusing. When you create a Virtual Machine if is actually contained in a Cloud Service but in the portal we hide this for you. If you instead list your Cloud Services in PowerShell you will see all the Cloud Services, including the once that have Virtual Machines connected to them. Just having a Cloud Service with nothing deployed to it does not incur any cost so for now we can just ignore it.

Next step is to delete the disk. Every disk for your Virtual Machines are stored in one of your own Windows Azure Storage Accounts. Storing data in a storage account incur cost so we need to delete this.

Click on the DISKS tab in Virtual Machines and note that before you can delete the disk the ATTACHED TO must be empty. It takes a couple of minutes between you deleting the Virtual Machine and the disk getting detached from that Virtual Machine.

DeleteVM4 

So be patient, what until the disk is released and then click on DELETE with the disk selected. When clicking on DELETE you are presented with two options. Either you Delete the associated VHD or you Retain the associated VHD. If you want to achieve zero cost you have to delete the VHD. But please remember that this will not be a reversible action and the VHD will be delete from your account.

DeleteVM5

With the Virtual Machine deleted and with the VHD associated with the disk attached to the Virtual Machine you are now down to zero in cost for you account. If you want you can now also delete the Cloud Service and the Storage Account by just selecting the corresponding tabs and select delete.

Inga kommentarer: