Social Icons

twitter google plus linkedin rss feed

Pages

29.7.14

Azure VM Snapshots Even Simpler

I have been thinking about taking and restoring snapshots of my Azure Virtual Machines for a while but never had the time to do it... until today.

It is extremely easy when you know how to do it but it could be a bit daunting when you have to start from scratch and as I have to write a post explaining it and it was about time for me to write another post in my blog I thought it could be a good idea to do it here.

From the beginning:
Luckily by now you will have it working.

Now the real thing. Chris Clayton has created a set of scripts that work wonderfully for managing Azure VM Screenshots and that is what I am using right now. If you are too lazy to go to the page and find the link you can get the scripts from here.
The only thing you need to configure is the Subscriptions.csv file. It's a CSV file so in the first line you have the column names and in the rest of them you have the data. It looks like this:
SubscriptionName,SubscriptionId,CertificateThumbprint
"IT","XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX","XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
This file will make the executing the commands easier as it has all the information about the subscription(s) that you are going to use. Yes, cool but... where to I get the data? look.

First, to get all the information we need about our subscription in PowerShell we can run:
Get-AzureSubscription
That will give us a screen like this one:
 Those are the parameters you need to fill in. Simple stuff.

Finally in order to run the commands you will have to provide data about which subscription to use and inside it which virtual machine. Simple stuff, we get the list of virtual machines we have in our subscription executing Get-AzureVM and we will get a screen like this one:


Now we have all the parameters we need. Just for testing it we will launch the script for getting the list of snapshots in a virtual machine.


./GetSnapshotList.ps1 -subscriptionName "NameOfTheSubscription" -cloudServiceName "ServiceName" -virtualMachineName "Name" -maximumDays 15
Where:
  • -subscriptionName is the SubscriptionName you got from Get-AzureSubscription and then wrote in Subscriptions.csv
  • -cloudServiceName is the ServiceName column you can see at Get-AzureVM
  • -virtualMachineName is the Name column you can see at Get-AzureVM

And that's it.

Things to remember:
  • The VM should be shut down before taking the snapshot (there's a handy parameter for that in the PowerShell command)
  • The data in your "Temporary Storage" drives will not be backed up or restored because they are temporary. Yes I knew it was going to work that way but I had to try.

As a test I took a snapshot of one of my SharePoint development machines, made some changes, restored it and so how the changes were reverted, just as expected. And I would even say faster than I expected.