Skip to content

Commit f1bd829

Browse files
author
Maddie Clayton
authored
Merge pull request #8611 from MabOneSdk/mercury_dev_test
[Recoveryservices] Removed VMappContainer check in get protectable item and adding PM reviews
2 parents 7b151c1 + f76c6c0 commit f1bd829

File tree

18 files changed

+168461
-129192
lines changed

18 files changed

+168461
-129192
lines changed

src/RecoveryServices/RecoveryServices.Backup.Models/CommonModels/Enums.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ public enum BackupType
367367
/// </summary>
368368
public enum ProtectableItemType
369369
{
370-
SQLDataBase,
370+
SQLDataBase = 1,
371371
SQLInstance,
372372
SQLAvailabilityGroup
373373
}

src/RecoveryServices/RecoveryServices.Backup.Models/Properties/Resources.Designer.cs

Lines changed: 12 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/RecoveryServices/RecoveryServices.Backup.Models/Properties/Resources.resx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,12 +554,15 @@ Please contact Microsoft for further assistance.</value>
554554
<value>The specified workload is already registered in the given resource ID</value>
555555
</data>
556556
<data name="AzureWorkloadRestoreProtectableItemException" xml:space="preserve">
557-
<value>Provide SQLInstance or SQLAvailabilityGroup protectable item in TargetItem</value>
557+
<value>Provide SQLInstance protectable item in TargetItem</value>
558558
</data>
559559
<data name="RegisterContainerMessage" xml:space="preserve">
560560
<value>Registering container</value>
561561
</data>
562562
<data name="RegisterContainerWarning" xml:space="preserve">
563563
<value>Are you sure you want to disable protection for the container '{0}'</value>
564564
</data>
565+
<data name="AzureWorkloadRestoreLocationException" xml:space="preserve">
566+
<value>Please provide the target of the restore operation using the switch -OriginalWorkloadRestore or -AlternateWorkloadRestore</value>
567+
</data>
565568
</root>

src/RecoveryServices/RecoveryServices.Backup.ServiceClientAdapter/BMSAPIs/ItemAPIs.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,5 +244,36 @@ public List<ProtectionIntentResource> ListProtectionIntent(
244244

245245
return HelperUtils.GetPagedList(listAsync, listNextAsync);
246246
}
247+
248+
/// <summary>
249+
/// Lists workload items according to the query filter and the pagination params
250+
/// </summary>
251+
/// <param name="containrName">Query filter</param>
252+
/// <param name="queryFilter">Query filter</param>
253+
/// <param name="skipToken">Skip token for pagination</param>
254+
/// <returns>List of protectable items</returns>
255+
public List<WorkloadItemResource> ListWorkloadItem(
256+
string containerName,
257+
ODataQuery<BMSWorkloadItemQueryObject> queryFilter,
258+
string skipToken = default(string),
259+
string vaultName = null,
260+
string resourceGroupName = null)
261+
{
262+
Func<RestAzureNS.IPage<WorkloadItemResource>> listAsync =
263+
() => BmsAdapter.Client.BackupWorkloadItems.ListWithHttpMessagesAsync(
264+
vaultName ?? BmsAdapter.GetResourceName(),
265+
resourceGroupName ?? BmsAdapter.GetResourceGroupName(),
266+
AzureFabricName,
267+
containerName,
268+
queryFilter,
269+
cancellationToken: BmsAdapter.CmdletCancellationToken).Result.Body;
270+
271+
Func<string, RestAzureNS.IPage<WorkloadItemResource>> listNextAsync =
272+
nextLink => BmsAdapter.Client.BackupWorkloadItems.ListNextWithHttpMessagesAsync(
273+
nextLink,
274+
cancellationToken: BmsAdapter.CmdletCancellationToken).Result.Body;
275+
276+
return HelperUtils.GetPagedList(listAsync, listNextAsync);
277+
}
247278
}
248279
}

src/RecoveryServices/RecoveryServices.Backup.Test/ScenarioTests/AzureWorkload/ItemTests.ps1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ $resourceGroupName = "pstestwlRG1bca8"
1717
$vaultName = "pstestwlRSV1bca8"
1818
$resourceId = "/subscriptions/da364f0f-307b-41c9-9d47-b7413ec45535/resourceGroups/pstestwlRG1bca8/providers/Microsoft.Compute/virtualMachines/pstestwlvm1bca8"
1919
$policyName = "HourlyLogBackup"
20+
$instanceName = "sqlinstance;mssqlserver"
2021

2122
function Test-AzureVmWorkloadProtectableItem
2223
{
@@ -58,6 +59,16 @@ function Test-AzureVmWorkloadProtectableItem
5859
-ItemType "SQLDataBase";
5960
Assert-True { $protectableItems.ProtectableItemType -contains "SQLDataBase" }
6061
Assert-False { $protectableItems.ProtectableItemType -contains "SQLInstance" }
62+
63+
$protectableItems = Get-AzRecoveryServicesBackupProtectableItem `
64+
-VaultId $vault.ID `
65+
-Container $container `
66+
-WorkloadType "MSSQL" `
67+
-Name $instanceName `
68+
-ServerName $containerName;
69+
70+
Assert-True { $protectableItems.ProtectableItemType -contains "SQLInstance" }
71+
Assert-True { $protectableItems.Count -eq 1}
6172
}
6273
finally
6374
{

0 commit comments

Comments
 (0)