![]() $status = $copy | Get-AzureStorageBlobCopyState $copy = Start-AzureStorageBlobCopy -SrcBlob $diskBlob -SrcContainer "vhds" -DestBlob $backupDiskBlob -DestContainer "vhds" -Context $ctx -Verbose $blobCount = Get-AzureStorageBlob -Container vhds -Context $ctx | where $ctx = New-AzureStorageContext -StorageAccountName $storageAccount -StorageAccountKey $storageAccountKey Select-AzureSubscription -SubscriptionName $subscriptionName $backupDiskBlob = " $diskName-backup.vhd" ![]() $storageAccountKey = "Enter Storage Key Here" All subsequent times you run the script it will reset it to that snapshot. The first time you run the script it will create the initial snapshot. 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. Lastly, I need to copy the Storage Account Access Key for use in the powershell. You can set this in the configuration page for the Public IP resource. 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. If you want to try it out, here's a step-by-step to try it out:įirst create a VM in Azure, and be sure to select Resource Manager as the deployment model:Īfter it's done processing we'll have a new Resource Group with 6 resources included: Note: This is all done using ARM (Azure Resource Manager) style VM'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. 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. We still can't do actual snapshots, but I've written some powershell that achieves the same goal. 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. I've always been frustrated that I can't do snapshots when I'm using VM's in Azure.
0 Comments
Leave a Reply. |