Taking VHD snapshot with Windows Azure Virtual Machines
June 15, 2012 6 Comments
One very useful capability of virtualisation (in general) is the ability to take snapshots of a disk at a point in time, allowing restoring the machine to a known state quickly and easily.
With Windows Azure Virtual Machines one does not have access to the hypervisor (for obvious reasons!), so could this be achieved?
The answer is – by taking a snapshot of the underlying blob on which the VHD is stored.
To demonstrate I’ve created a brand new Machine from the galley – I’ve used the SQL template-
I then went ahead and created a quick database and added several rows to it through the SQL Management Console -
At this point, using Cerebrata’s Cloud Storage Studio in my case, I took a snapshot of the blob containing the VHD
With the snapshot taken I went ahead and removed the table, only to create a new one with slightly different structure and values, to make sure the state of the machine had changed since I took the snapshot -
Now I wanted to restore it to it’s previous state.
I could chose to do that to a brand new machine or to override the existing machine, the later would of course require that I first remove the machine (and disk) from the management portal so that the lease on the underlying blob would be returned making it writable, and that’s what I’ve done. If I wanted to create a new machine I would have used the CopyBlob capability to copy the snapshot to a new blob, making it writable (snapshots are read only), and then create a disk and machine out of that, next to my existing machine.
In my case I wen on to delete the Virtual Machine and the related disk and, using Storage Studio again in my case, I ‘promoted’ the snapshot – tthis simply copies the snapshot back to the original blob.
With this done, I now have the older snapshot as the current blob, and it was time to re-create the disk..
…and virtual machine -
..and sure enough, once the machine finished started I connected to it and looked at the databases using SQL Management studio again, which contained the original database and values, as expected -
Quick update – I have added a post about how to do this from PowerShell, read it here