Skip to content

Commit

Permalink
VM restore fix for #7823
Browse files Browse the repository at this point in the history
  • Loading branch information
siddharth7 committed Nov 28, 2018
1 parent 821f8f2 commit a7c2805
Show file tree
Hide file tree
Showing 7 changed files with 756,212 additions and 16,545 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public RestAzureNS.AzureOperationResponse TriggerRestore()
CreateNewCloudService = false,
RecoveryPointId = rp.RecoveryPointId,
RecoveryType = RecoveryType.RestoreDisks,
Region = vaultLocation,
Region = vaultLocation ?? ServiceClientAdapter.BmsAdapter.GetResourceLocation(),
StorageAccountId = storageAccountResource.Id,
SourceResourceId = rp.SourceResourceId,
TargetResourceGroupId = targetResourceGroupName != null ?
Expand All @@ -315,7 +315,7 @@ public RestAzureNS.AzureOperationResponse TriggerRestore()
triggerRestoreRequest,
vaultName: vaultName,
resourceGroupName: resourceGroupName,
vaultLocation: vaultLocation);
vaultLocation: vaultLocation ?? ServiceClientAdapter.BmsAdapter.GetResourceLocation());
return response;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public RestAzureNS.AzureOperationResponse RestoreDisk(
string resourceGroupName = null,
string vaultLocation = null)
{
vaultLocation = vaultLocation ?? BmsAdapter.GetResourceLocation();
Dictionary<UriEnums, string> uriDict = HelperUtils.ParseUri(rp.Id);
string containerUri = HelperUtils.GetContainerUri(uriDict, rp.Id);
string protectedItemUri = HelperUtils.GetProtectedItemUri(uriDict, rp.Id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public partial class ServiceClientAdapter
const string AzureFabricName = "Azure";
public const string ResourceProviderProductionNamespace = "Microsoft.RecoveryServices";

ClientProxy<RecoveryServicesBackupNS.RecoveryServicesBackupClient> BmsAdapter;
public ClientProxy<RecoveryServicesBackupNS.RecoveryServicesBackupClient> BmsAdapter;

ClientProxy<RecoveryServicesNS.RecoveryServicesClient> RSAdapter;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,10 @@ function Test-AzureVMSetVaultContext
# Setup
$vm = Create-VM $resourceGroupName $location
$vault = Create-RecoveryServicesVault $resourceGroupName $location
$saName = Create-SA $resourceGroupName $location

# Sleep to give the service time to add the default policy to the vault
Start-TestSleep 5000
Start-TestSleep 5000

Set-AzureRmRecoveryServicesVaultContext -Vault $vault

Expand All @@ -384,6 +385,24 @@ function Test-AzureVMSetVaultContext
-Container $container `
-WorkloadType AzureVM

$backupJob = Backup-AzureRmRecoveryServicesBackupItem `
-Item $item | Wait-AzureRmRecoveryServicesBackupJob;

# Get Recovery Point
$backupStartTime = $backupJob.StartTime.AddMinutes(-1);
$backupEndTime = $backupJob.EndTime.AddMinutes(1);
$rps = Get-AzureRmRecoveryServicesBackupRecoveryPoint `
-Item $item `
-StartDate $backupStartTime `
-EndDate $backupEndTime

# Restore item
$restoreJob1 = Restore-AzureRmRecoveryServicesBackupItem `
-RecoveryPoint $rps[0] `
-StorageAccountName $saName `
-StorageAccountResourceGroupName $resourceGroupName | `
Wait-AzureRmRecoveryServicesBackupJob

# Disable protection
Disable-AzureRmRecoveryServicesBackupProtection `
-Item $item `
Expand Down
772,725 changes: 756,187 additions & 16,538 deletions ...ands.RecoveryServices.Backup.Test.ScenarioTests.ItemTests/TestAzureVMSetVaultContext.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
## Current Release
* Added client side validations for Azure File Share restore operations.
* Made storageAccountName and storageAccountResourceGroupName optional for afs restore.
* Fixed restore cmdlet while using Set-vaultContext.

## Version 4.5.1
* Fix for modifying policy for a protected file share.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ public abstract class RSBackupVaultCmdletBase : RecoveryServicesBackupCmdletBase
/// <summary>
/// ARM ID of the Recovery Services Vault.
/// </summary>
[Parameter(Mandatory = false, HelpMessage = "ARM ID of the Recovery Services Vault.",
ValueFromPipeline = true)]
[Parameter(Mandatory = false, HelpMessage = "ARM ID of the Recovery Services Vault.")]
[ValidateNotNullOrEmpty]
public string VaultId { get; set; }

Expand Down

0 comments on commit a7c2805

Please sign in to comment.