I know…this is another restore related post for unmanaged disk. I promise this is the last in this period… 🙂
So the concept is here for restore and you can find here the previous unmanaged disk related restore with several scripts. (the managed disk related steps are here) Now I would like to show you the amaretto related restore steps forl unmanaged disk based VM.
Some useful information before you start the restore:
Required naming convention
OS disk and Data disks related vhds must be in the following format:
- OS disk:
- Data disk:
- [vmname]-datadisk-[diskid].vhd (where the diskid represents the value of lun)
- (example for 1st data disk: myvm-datadisk-0.vhd)
- Linux OS
- Azure-Cli 2.x
- Python 2.7
- amaretto (Azure management tools by the1bit) package for python. You can download it from pypi and git as well.
In amaretto you can also find a restoreUnmanagedDiskFromVhd function in amarettorestore module which “do your job” regarding restore procedure.
What does this function do?
- Get restore file from restored container
- Download deploy file (generally this is a config.json with UTF-16 encoding(!))
- Check file encoding – if necessary it converts from UTF-16 to UTF-8
- Deallocate VM
- Delete VM object (ONLY)
- Get os disk information (restored vhd’s url)
- Delete old unmanaged disk
- Copy os disk to its original location
- Get data disk information (restored vhds’ url)
- Delete old unmanaged disk one-by-one
- Copy data disk to its original location
- Check restore result (whether all disks are restored or not)
And now let’s see the steps one-by-one:
1. Restore VM’s VHDs from backup vault
Choose the right restore point from Recovery Services vaults which belongs to target VM and Restore OSDisk and DataDisks to your storage account.
2. Configure and execute “restoreUnmanagedDiskFromVhd” function from amaretto
You have to execute the following commands with your VM related parameters from python:
# Your VM name vmName = "thisismyserver-1" # resource group name where the VM is located resourceGroup = "thisismyrg" # location where the resources are located. (westeurope, germanycentral, ...) location = "westeurope" # storage account name where the VM's restored vhds are stored sourceStorageAccount = "thisismystorage" # 1st or 2nd access key for sourceStorageAccount sourceSecretKey = "d22j/rr+a7br7LW6KDKV8KZkO2wCIe3m0MTKVr3Tt9B9NMZZsYxny8bvWvPwUGgZpDkE8gyAePjWCVu2IZ4LYw==" # name of container where the restored vhds are stored sourceContainer = "vhd6bdda0e88c88408299246c468784656546a" # Execute restore function amaretto.amarettorestore.restoreUnmanagedDiskFromVhd(vmName, resourceGroup, location, storageAccount, secretKey, sourceContainer)
3. Re-create target VM with your ARM Template
In this step you merely redeploy your vm from that ARM template you had created for original vm creation.
Next week I will provide a new topic to you… 🙂
If you need some help regarding ARM Template for restore or other scenarios do not hesitate to contact me.