diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackupClientAdapter/ItemAdapter.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackupClientAdapter/ItemAdapter.cs index 01ae2e555d8e..781eeb26ae52 100644 --- a/src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackupClientAdapter/ItemAdapter.cs +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackupClientAdapter/ItemAdapter.cs @@ -102,6 +102,18 @@ public IEnumerable ListRecoveryPoints(string container return (response != null) ? response.CSMRecoveryPointListResponse.Value : null; } + /// + /// Lists recovery points for specified item + /// + /// + /// + /// + public CSMRecoveryPointResponse GetRecoveryPoint(string containerName, string itemName, string recoveryPointName) + { + var response = AzureBackupClient.RecoveryPoint.GetAsync(GetCustomRequestHeaders(), containerName, itemName, recoveryPointName, CmdletCancellationToken).Result; + return (response != null) ? response.Value : null; + } + /// /// Lists recovery points for specified item /// diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/RecoveryPoint/GetAzureBackupRecoveryPoint.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/RecoveryPoint/GetAzureBackupRecoveryPoint.cs index 5152bae3408d..e6b8071777c3 100644 --- a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/RecoveryPoint/GetAzureBackupRecoveryPoint.cs +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/RecoveryPoint/GetAzureBackupRecoveryPoint.cs @@ -40,34 +40,34 @@ public override void ExecuteCmdlet() { WriteDebug("Making client call"); - var recoveryPointListResponse = AzureBackupClient.ListRecoveryPoints(Item.ContainerUniqueName, Item.ItemName); - - if (recoveryPointListResponse != null) + if (Id != null) { - WriteDebug("Received recovery point response"); - - IEnumerable recoveryPointObjects = null; - if (Id != null) + CSMRecoveryPointResponse recoveryPointObject = AzureBackupClient.GetRecoveryPoint(Item.ContainerUniqueName, Item.ItemName, Id); + if (recoveryPointObject != null) + { + WriteAzureBackupRecoveryPoint(recoveryPointObject, Item); + } + else + { + WriteDebug(string.Format("{0}{1}", "No recovery point exist with Id := ", Id)); + } + } + else + { + IEnumerable recoveryPointListResponse = AzureBackupClient.ListRecoveryPoints(Item.ContainerUniqueName, Item.ItemName); + if (recoveryPointListResponse != null && + recoveryPointListResponse.Count() > 0) { - CSMRecoveryPointResponse recoveryPointObject = null; - recoveryPointObjects = recoveryPointListResponse.Where(x => x.Name.Equals(Id, System.StringComparison.InvariantCultureIgnoreCase)); - if (recoveryPointObjects != null && recoveryPointObjects.Any()) + IEnumerable recoveryPointObjects = recoveryPointListResponse.OrderByDescending(x => x.Properties.RecoveryPointTime); + if (recoveryPointObjects.Count() > 1) { - WriteDebug("Converting response"); - recoveryPointObject = recoveryPointObjects.FirstOrDefault(); - WriteAzureBackupRecoveryPoint(recoveryPointObject, Item); + WriteAzureBackupRecoveryPoint(recoveryPointObjects, Item); } else { - WriteDebug(string.Format("{0}{1}", "No recovery point exist with Id := ", Id)); + WriteAzureBackupRecoveryPoint(recoveryPointObjects.FirstOrDefault(), Item); } } - else - { - WriteDebug("Converting response"); - recoveryPointObjects = recoveryPointListResponse.OrderByDescending(x => x.Properties.RecoveryPointTime); - WriteAzureBackupRecoveryPoint(recoveryPointObjects, Item); - } } }); } diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Resources/Microsoft.Azure.Management.BackupServicesManagement.dll b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Resources/Microsoft.Azure.Management.BackupServicesManagement.dll index eeb891120710..799f514df155 100644 Binary files a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Resources/Microsoft.Azure.Management.BackupServicesManagement.dll and b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Resources/Microsoft.Azure.Management.BackupServicesManagement.dll differ