There are benefits in task automation, beyond the obvious of time-saving. Task automation also reduces the chances of mistakes during the process, and ensures repeatability, regardless of who performs the task.
Last week, I was working with two customers who had two different use cases that lent themselves to the Veeam Restore to Microsoft Azure feature. Customer A wants to restore his production workload on Azure Cloud once a week to a test environment, from where his QA team can use the restored workload to perform their QA testing. Customer B wants to restore his production workload to Microsoft Azure in case of a disaster.
In both examples, Veeam offers a great feature to accomplish these tasks using the Veeam Backup and Replication product; but, to automate the tasks, I wrote a script to simplify the task for both customers using Veeam PowerShell.
With Customer B, I used a script with Veeam Availability Orchestrator (VAO) to orchestrate the process in the event of a disaster striking.
Let’s go now to a script I wrote for Customer A and examine how Customer B can benefit from the same script; but, with the help of VAO to simplify his disaster recovery procedures.
Preparing Azure for Veeam Restore
To get started, we need to ask ourselves two basic questions. First, if we want to create a virtual machine on Azure, what parameters must we have to accomplish the task? The second question, what Veeam Restore to Microsoft Azure features will be required?
The answer to the first question is that you will need these parameters:
- Azure Subscription
- Storage Account
- Azure Network
- Azure Storage Account
- and a Resource Group
- VM Size
The answer to the second question is that you will need these parameters:
- Backup Restore point
- Azure Subscription
- and all the above
Then, before we start writing our script, let’s first create the Azure Resource Group using these steps:
For the second step, let’s create the Azure Network that we will use:
And last, let’s create the storage account:
With those steps, we have completed the first stage of preparing Azure to receive the restored VM. Now we move to the next step:
Preparing Veeam Backup and Replication
Our next step is to prepare Veeam Backup and Replication for Microsoft Azure Restore, which includes registering your Azure Account into the Veeam console:
Note: To use the restore feature, you must install Azure Powershell.
Next, to create a backup for the VMs we are going to restore in this blog, I will be using a job called VAO_BackupJob, which contains one VM.
Preparing the Script – Part 1:
Now we will start the fun part of writing and preparing the script. For more detail, all the information and commands used in this section can be found at the following URL:
https://helpcenter.veeam.com/docs/backup/powershell/start-vbrvmrestoretoazure.html?ver=95u4
If you check that link above, you will notice that the Start-VBRVMRestoreToAzure command expects many parameters to successfully restore and create a VM on Azure. These parameters are as follows:
- Restore Point of the VM:
- From the VAO_BackupJob, extract the latest recovery point of a VM called “CrmSrv” and save on $AzureRecoveryPoint:
- $AzureRecoveyPoint = Get-VBRBackup “VAO_BackupJob” | Get-VBRRestorePoint -Name “CrmSrv” | Sort-Object -Property CreationTime -Descending | Select -First 1
- From the VAO_BackupJob, extract the latest recovery point of a VM called “CrmSrv” and save on $AzureRecoveryPoint:
- Azure Subscription
- To get the Azure subscription details you need to first get your account details stored within Veeam console and then through the account, you will be able to retrieve the subscription details and save into parameters as below:
- $AzureAccount = Get-VBRAzureAccount
- $AzureSub = Get-VBRAzureSubscription -Account $AzureAccount -Name “<Subscription Name is you have more than one>”
- To get the Azure subscription details you need to first get your account details stored within Veeam console and then through the account, you will be able to retrieve the subscription details and save into parameters as below:
- Azure Storage Account
- $AzureStorageAcc = Get-VBRAzureStorageAccount -Subscription $AzureSub -Name vaoworkload
- Azure VM size
- $AzureVMSize = Get-VBRAzureVMSize -Subscription $AzureSub -Location $AzureLocation -Name Standard_G2
- Azure Network
- $AzureNet = Get-VBRAzureVirtualNetwork -Subscription $AzureSub -Name VAONet
- Azure Location
- $AzureLocation = Get-VBRAzureLocation -Subscription $AzureSub -Name australiaeast
- and Azure Resource Group
- $AzureResource = Get-VBRAzureResourceGroup -Subscription $AzureSub -Name DR_Workload
Preparing the Script – Part 2:
At Part 1, we went through each command to retrieve certain information and save it as an environment parameter; therefore, to be able to use the Microsoft Azure Restore feature from Veeam PowerShell, we need to use the following Veeam Powershell command incorporating all those parameters above in one Veeam PowerShell command:
Start-VBRVMRestoreToAzure -RestorePoint $AzureRecoveyPoint -Subscription $AzureSub -StorageAccount $AzureStorageAcc -VmSize $AzureVMSize -VirtualNetwork $AzureNet -VirtualSubnet $AzureSubNet -ResourceGroup $AzureResource -VmName VAORecove01 -Reason “Recover From VAO”
Using that command will restore the latest Recovery point of the CrmSrv VM to Azure Subscription with the following parameters:
- VM size: Standard_G2,
- Storage Account: vaoworkload
- Network: VAONet
- Location: AusEast
- ResourceGroup: DR_Workload
The complete Script is:
Recover to Azure with VAO:
Note: Veeam Availability Orchestrator will not offer a DR to a public cloud (Azure in this example). The example in this blog post is about workload Recover to the Azure Cloud in case of a disaster; i.e. Restore from backup targeting Azure Cloud.
For Customer B to start using the script above to recover the VM to Azure using VAO, he has to save the Veeam PowerShell script on the VAO server and add it to the VAO Plan Steps:
…and then include it on the Orchestration Plan:
Summary
On this blog post, I demonstrated two use cases of Veeam Restore to Microsoft Azure for two different customers who want to achieve two different outcomes; but, using the same Veeam feature. Both customers can use Veeam Console to achieve the same result. With basic Veeam Powershell scripts, they were able to automate the entire process and make it simple for execution. Using VAO, Customer B was able to execute an Orchestration plan where the VM automatically restored to Azure, instead of locally, in the event of a disaster.
What do you think?
[…] of people who work at Veeam, Hal has put together a great article on orchestrating Veeam recovery activities to […]