I've always been frustrated that I can't do snapshots when I'm using VM's in Azure. Especially when I'm developing some deployment automation, I like to be able to try something out - and when it inevitably screws up - reset the VM to a snapshot and try again.
We still can't do actual snapshots, but I've written some powershell that achieves the same goal. It will grab a copy of the VHD file (this acts as the snapshot), then when we want to restore to snapshot we'll just swap out the VHD's. The trick here is that Azure won't let you swap out the VHD for an existing VM, so we need to actually destroy the VM, swap out the VHD's, then recreate the VM using the existing VHD.
Note: This is all done using ARM (Azure Resource Manager) style VM's.
If you want to try it out, here's a step-by-step to try it out:
First create a VM in Azure, and be sure to select Resource Manager as the deployment model:
After it's done processing we'll have a new Resource Group with 6 resources included:
One thing I like to do - that the wizard doesn't let you specify - is to assign a DNS name to the public IP that I'll use to connect to my VM. You can set this in the configuration page for the Public IP resource.
Lastly, I need to copy the Storage Account Access Key for use in the powershell.
Now all we need to do is take the powershell below, and modify the values of the variables at the start to match the names you used when you created the VM/Resource Group.
The first time you run the script it will create the initial snapshot. All subsequent times you run the script it will reset it to that snapshot.