Friday 14 April 2017

Azure: Create Managed Disk from a Snapshot

Azure: Create Managed Disk from a Snapshot


So, today I was looking at Managed Disks and using one to store SQL backups from inside a VM. Then I looked at backups but I'd prefer not to backup the whole VM just to capture the SQL bak file. I could set a weekly backup job to capture the OS and Application, but how to get a daily backup of the SQL BAK files?

I'm using Managed Disks and while you can create a snapshot through the web interface, you can't do anything with the snapshots currently, except list them!

So, I read over and over how it was possible to create a Managed Disk using a snapshot. Great I thought, but how?!! So I got this to work with the new CLI 2.0 as follows:

Uninstall any old Python versions on windows. Grab the latest 64 bit version from the python website.
https://www.python.org/downloads/windows/
Install and choose to add it to your path. After I did this I ran into an issue installing azure-cli. This is when I found an old version of pip & python - unintalled this and the new Phython and reinstalled the latest 64 bit one and the azure-cli installed fine
https://docs.microsoft.com/en-us/cli/azure/install-azure-cli
Now it wouldn't invoke the command "az". I'd to add the following to my path in windows 10:
"C:\Users\<username>\AppData\Roaming\Python\Python36\Scripts"
Now I could invoke az and log into Azure using "az login"
After that I created a managed disk from one of the snapshots I'd previously created:
https://azure.microsoft.com/en-us/blog/azure-cli-managed-disks/

az disk create -n myDisk -g MYPRICINGRG --source /subscriptions/<------------>/resourceGroups/MYPRICINGRG/providers/Microsoft.Compute/snapshots/140417

You can get the source by copying the RESOURCE ID from the screen below.
You can add snapshots to your Azure service bar on the left for handy retrieval.

Now you can attach this new managed disk to your SQL or other VM as an additional disk and away you go!


Looks like CLI 2.0 is becoming the defacto standard for Azure?