Tuesday 11 October 2016

Create Snapshots of an Azure RM VM


Powershell Functions for Creating Azure RM VM Snapshots


Load the Functions:
C:> . .\AzureSnapFunctions.PS1

Create a New snapshot for all VHDs in a VM
C:> Snap-AzureRMVM -VMName MyVM -SnapshotName "Snap 1"

View the snapshots for all VHDs on a VM
C:> Get-AzureRMVMSnap -VMName MyVM

Delete all snapshots for all VHDs on a VM
C:> Delete-AzureRMVMSnap -VMName MyVM

Revert to a snapshot for all VHDs on a VM
C:> Revert-AzureRMVMSnap -VMName MyVM


  1. Nice functions, going to try them out shortly. Thank you.

  2. Dave. I greatly appreciate all the work you did here, it saved me quite a bit of time. I ended up updating your revert function from the github site due to some issues I had with it reverting multi-disk vm's. I'm not much of a powershell guy, but was able to get it to revert azure vm's with multiple disks. Please let me know if you would be interested in my updates and I'll be happy to send them to you.

    1. Absolutely interested in any fixes or improvements you may have. Thank you.

    2. Hi JC,

      Reversion on multi-disk VMs should now be working.


  3. This comment has been removed by the author.

  4. Hi Dave,

    I'm trying to use your script, and I'm coming across an error during the first call to Get-StorageTable(), where New-AzureStorageTable is called, and hoping you'd be able to help me.

    The full error message is:
    New-AzureStorageTable : The remote name could not be resolved: 'XXXXXXdisks389.table.core.windows.net'
    At C:\Users\YYYYY\Documents\GitHub\Azure-VM-Snapshots\AzureStorageFunctions.PS1:26 char:20
    + ... SnapTable = New-AzureStorageTable -Name $TableName -Context $StorageC ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : CloseError: (:) [New-AzureStorageTable], StorageException
    + FullyQualifiedErrorId : StorageException,Microsoft.WindowsAzure.Commands.Storage.Table.Cmdlet.NewAzureStorageTableCom

    XXXXXXdisks389 is a Premium Performance, Locally Redundant storage account that was created during the VM creation. Is there a prerequisite to what the storage account type should be to use your script?

    1. Answering my own question here, but it looks like it has to be a Standard Performance storage account for this to work, since the Premium only supports Azure virtual machine disks. https://azure.microsoft.com/en-us/documentation/articles/storage-introduction/

    2. Hi,

      I've only tested with standard RM storage accounts, the New-AzureStorageTable function creates and writes to an Azure table so I guess it's not going to work if that's not supported.

      It may have actually created a snapshot of the disk, but not tracked it using the table.

      If you run Get-AzureRMVMSnapBlobs on the VM does it return any snapshots?


  5. Hi Dave,
    I just checked it and yes, it looks like the snapshot did get created!
    I didn't think it did b/c of all the red error messages.

    The tables would be a really nice feature to have, but I guess not absolutely essential for me at this point.

    Thank you for this, by the way!

  6. I have a query.. My case is below :
    we have a pre-prod server created in Region-1 .. now we want to create the exact copy of pre-prod server in region-2 . how can i achieve that. what they expect me is to create a new VM in region-2 using the snapshop of region-1 VM and Also keep the Pre-prod server for region-1 intact.

    1. My advice would be to stop the VM, then use AzCopy, PowerShell or Storage Explorer to copy the VHD for the VM to the other region.

      Then I would use PowerShell or JSON template to create a new VM with the copied VHD(s) attached.

      I think this link should help:



Please be nice! :)

Nutanix CE 2.0 on ESXi AOS Upgrade Hangs

AOS Upgrade on ESXi from 6.5.2 to hangs. Issue I have tried to upgrade my Nutanix CE 2.0 based on ESXi to a newer AOS version for ...