Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.Backup" Version="4.0.1-preview" />
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.Backup" Version="4.1.2-preview" />
<PackageReference Include="TimeZoneConverter" Version="3.0.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// ----------------------------------------------------------------------------------

using System;
using Microsoft.Azure.Management.RecoveryServices.Backup.Models;
using Microsoft.WindowsAzure.Commands.Utilities.Common;
using RestAzureNS = Microsoft.Rest.Azure;
using ServiceClientModel = Microsoft.Azure.Management.RecoveryServices.Backup.Models;
Expand Down Expand Up @@ -110,6 +111,31 @@ public static RestAzureNS.AzureOperationResponse GetOperationResult(
return opStatusResponse;
}

/// <summary>
/// Block to track the operation to completion.
/// Waits till the status of the data-move operation is InProgress.
/// </summary>
/// <param name="response">Response of the operation returned by the service.</param>
/// <param name="getOpStatus">Delegate method to fetch the operation status of the operation.</param>
/// <returns>Result of the operation once it completes.</returns>
public static RestAzureNS.AzureOperationResponse<T> GetOperationStatusDataMove<T>(
RestAzureNS.AzureOperationResponse response,
Func<string, RestAzureNS.AzureOperationResponse<T>> getOpStatus)
where T: ServiceClientModel.OperationStatus
{
var operationId = response.Response.Headers.GetOperationResultId();
var opStatusResponse = getOpStatus(operationId);

while (opStatusResponse.Body.Status == "InProgress")
{
TestMockSupport.Delay(_defaultSleepForOperationTracking * 1000);
opStatusResponse = getOpStatus(operationId);
}
opStatusResponse = getOpStatus(operationId);

return opStatusResponse;
}

/// <summary>
/// Block to track the operation to completion.
/// Waits till the HTTP status code of the operation becomes something other than Accepted.
Expand All @@ -123,18 +149,29 @@ public static RestAzureNS.AzureOperationResponse<T> GetOperationResult<T>(
where T: ServiceClientModel.ProtectionContainerResource
{
var operationId = response.Response.Headers.GetOperationResultId();

var opStatusResponse = getOpStatus(operationId);

while (opStatusResponse.Response.StatusCode == SystemNet.HttpStatusCode.Accepted)
{
TestMockSupport.Delay(_defaultSleepForOperationTracking * 1000);

opStatusResponse = getOpStatus(operationId);
}

opStatusResponse = getOpStatus(operationId);
return opStatusResponse;
}

/// <summary>
/// This method is used to fetch the prepare data move CorrelationId.
/// </summary>
/// <param name="response">Response of the operation returned by the service.</param>
/// <param name="getCorrelationId">Delegate method to fetch the correlation id of the operation.</param>
/// <returns>Result of the operation once it completes.</returns>
public static PrepareDataMoveResponse GetCorrelationId(
RestAzureNS.AzureOperationResponse response,
Func<string, PrepareDataMoveResponse> getCorrelationId)
{
var operationId = response.Response.Headers.GetAzureAsyncOperationId();
var opStatusResponse = getCorrelationId(operationId);
return opStatusResponse;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,12 @@ public enum JobOperation
/// <summary>
/// Disable protection with delete data
/// </summary>
DeleteBackupData
DeleteBackupData,

/// <summary>
/// Data move between source and target vaults
/// </summary>
BackupDataMove
}

/// <summary>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -604,4 +604,10 @@ Please contact Microsoft for further assistance.</value>
<data name="AzureFileSourceFilePathRedundantException" xml:space="preserve">
<value>Both source file path and multiple source file paths provided. Please give only one option</value>
</data>
<data name="TargetVaultNotEmptyException" xml:space="preserve">
<value>Please provide an empty target vault. The target vault should not have any backup items or backup containers</value>
</data>
<data name="TargetVaultStorageRedundancy" xml:space="preserve">
<value>Are you sure you want to copy items to the {0} whose storage redundancy is {1}</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.Backup" Version="4.0.1-preview" />
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.Backup" Version="4.1.2-preview" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<PsModuleName>RecoveryServices</PsModuleName>
Expand All @@ -12,7 +12,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.Backup" Version="4.0.1-preview" />
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.Backup" Version="4.1.2-preview" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,23 @@ public IEnumerable<ProtectableContainerResource> ListUnregisteredContainers(
return HelperUtils.GetPagedList(listAsync, listNextAsync);
}

/// <summary>
/// Gets Backup Usage Summary - registered containers/items within the vault
/// </summary>
/// <returns></returns>
public IEnumerable<BackupManagementUsage> GetBackupUsageSummary(string vaultName, string resourceGroupName,
ODataQuery<BMSBackupSummariesQueryObject> queryFilter)
{
Func<IEnumerable<BackupManagementUsage>> listAsync = () => BmsAdapter.Client.BackupUsageSummaries.ListWithHttpMessagesAsync(
vaultName,
resourceGroupName,
queryFilter,
skipToken: null,
cancellationToken: BmsAdapter.CmdletCancellationToken).Result.Body;

return listAsync();
}

/// <summary>
/// Triggers refresh of container catalog in service
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Management.RecoveryServices.Backup.Models;
using RestAzureNS = Microsoft.Rest.Azure;
using ServiceClientModel = Microsoft.Azure.Management.RecoveryServices.Backup.Models;

Expand Down Expand Up @@ -99,6 +100,42 @@ public RestAzureNS.AzureOperationResponse<ServiceClientModel.ProtectionContainer
operationId).Result;
}

/// <summary>
/// Gets status of prepare data move operation on the source vault
/// </summary>
/// <param name="operationId">ID of the operation in progress</param>
/// <returns></returns>
public RestAzureNS.AzureOperationResponse<ServiceClientModel.OperationStatus>
GetDataMoveOperationStatus(
string operationId,
string vaultName = null,
string resourceGroupName = null)
{
return BmsAdapter.Client.GetOperationStatusWithHttpMessagesAsync(
vaultName,
resourceGroupName,
operationId).Result;
}

/// <summary>
/// Gets correlationId result of prepare data move operation on the source vault
/// </summary>
/// <param name="operationId">ID of the operation in progress</param>
/// <returns></returns>
public ServiceClientModel.PrepareDataMoveResponse
GetPrepareDataMoveOperationResult(
string operationId,
string vaultName = null,
string resourceGroupName = null)
{
PrepareDataMoveResponse prepareResponse = BmsAdapter.Client.BMSPrepareDataMoveOperationResult.BeginGetWithHttpMessagesAsync(
vaultName,
resourceGroupName,
operationId).Result.Body;

return prepareResponse;
}

/// <summary>
/// Gets result of the cancel operation on the job using the operation ID
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,17 @@ public BackupResourceVaultConfigResource GetVaultProperty(string vaultName, stri
return BmsAdapter.Client.BackupResourceVaultConfigs.GetWithHttpMessagesAsync(
vaultName, resourceGroupName).Result.Body;
}

/// <summary>
/// Method to Get Azure Recovery Services Vault Backup Properties
/// </summary>
/// <param name="resouceGroupName">Name of the resouce group</param>
/// <param name="vaultName">Name of the vault</param>
/// <returns>Azure Resource Storage response object.</returns>
public BackupResourceConfigResource GetVaultStorageType(string resouceGroupName, string vaultName)
{
return BmsAdapter.Client.BackupResourceStorageConfigs.GetWithHttpMessagesAsync(
vaultName, resouceGroupName).Result.Body;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices" Version="4.3.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.Backup" Version="4.0.1-preview" />
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.Backup" Version="4.1.2-preview" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.4.1" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="38.1.0" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.0.2-preview" />
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices" Version="4.3.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.Backup" Version="4.0.1-preview" />
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.Backup" Version="4.1.2-preview" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function Create-VM(
$tags += @{"AutoShutDown"="No"}
$tags += @{"DeleteBy"="05-2020"}

$vmConfig = New-AzVMConfig -VMName $vmName -VMSize Standard_D1 | `
$vmConfig = New-AzVMConfig -VMName $vmName -VMSize Standard_D1_v2 | `
Set-AzVMOperatingSystem -Windows -ComputerName $vmName -Credential $Credential | `
Set-AzVMSourceImage -PublisherName MicrosoftWindowsServer -Offer WindowsServer `
-Skus 2016-Datacenter -Version latest | Add-AzVMNetworkInterface -Id $nic.Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,14 @@ public void TestAzureVMDiskExclusion()
TestController.NewInstance.RunPsTest(
_logger, PsBackupProviderTypes.IaasVm, "Test-AzureVMDiskExclusion");
}

[Fact(Skip = "CCY region is down and the testing for DS Move is restricted")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(TestConstants.Workload, TestConstants.AzureVM)]
public void TestAzureBackupDataMove()
{
TestController.NewInstance.RunPsTest(
_logger, PsBackupProviderTypes.IaasVm, "Test-AzureBackupDataMove");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,32 @@
# limitations under the License.
# ----------------------------------------------------------------------------------

function Test-AzureBackupDataMove
{
$sourceLocation = "eastus2euap"
$sourceResourceGroup = Create-ResourceGroup $sourceLocation 21

$targetLocation = "centraluseuap"
$targetResourceGroup = Create-ResourceGroup $targetLocation 23

$vm = Create-VM $sourceResourceGroup $sourceLocation 3
$vault1 = Create-RecoveryServicesVault $sourceResourceGroup $sourceLocation
$vault2 = Create-RecoveryServicesVault $targetResourceGroup $targetLocation
Enable-Protection $vault1 $vm

# disable soft delete for successful cleanup
Set-AzRecoveryServicesVaultProperty -VaultId $vault1.ID -SoftDeleteFeatureState "Disable"
Set-AzRecoveryServicesVaultProperty -VaultId $vault2.ID -SoftDeleteFeatureState "Disable"

# data move v2 to v1 fails due to TargetVaultNotEmpty
Assert-ThrowsContains { Copy-AzRecoveryServicesVault -SourceVault $vault2 -TargetVault $vault1 -Force } `
"Please provide an empty target vault. The target vault should not have any backup items or backup containers";

# data move from v1 to v2 succeeds
$dataMove = Copy-AzRecoveryServicesVault -SourceVault $vault1 -TargetVault $vault2 -Force;
Assert-True { $dataMove -contains "Please monitor the operation using Az-RecoveryServicesBackupJob cmdlet" }
}

function Test-AzureVMGetItems
{
$location = "southeastasia"
Expand Down
Loading