// filter items from secondary region public List <CmdletModel.ItemBase> ListProtectedItemsByItemNameCrr( List <CrrModel.ProtectedItemResource> protectedItems, string itemName, string vaultName, string resourceGroupName, Action <CmdletModel.ItemBase, ProtectedItemResource> extendedInfoProcessor, string friendlyName = null) { List <ProtectedItemResource> protectedItemGetResponses = new List <ProtectedItemResource>(); if (!string.IsNullOrEmpty(itemName) || !string.IsNullOrEmpty(friendlyName)) { protectedItems = protectedItems.Where(protectedItem => { Dictionary <CmdletModel.UriEnums, string> dictionary = HelperUtils.ParseUri(protectedItem.Id); string protectedItemUri = HelperUtils.GetProtectedItemUri(dictionary, protectedItem.Id); bool filteredByUniqueName = itemName != null && (protectedItemUri.ToLower().Contains(itemName.ToLower())); bool filteredByFriendlyName = false; if (protectedItem.Properties.BackupManagementType == "AzureStorage" && protectedItem.Properties.WorkloadType == "AzureFileShare") { // code should never reach here, as CRR is not supported for azure files yet string protectedItemFriendlyName = (protectedItem.Properties as CrrModel.AzureFileshareProtectedItem).FriendlyName; filteredByUniqueName = filteredByUniqueName || (itemName != null && protectedItemFriendlyName.ToLower() == itemName.ToLower()); filteredByFriendlyName = friendlyName != null && protectedItemFriendlyName.ToLower() == friendlyName.ToLower(); } return(filteredByUniqueName || filteredByFriendlyName); }).ToList(); // bug: below API calls should be made to secondary region ODataQuery <GetProtectedItemQueryObject> getItemQueryParams = new ODataQuery <GetProtectedItemQueryObject>(q => q.Expand == "extendedinfo"); for (int i = 0; i < protectedItems.Count; i++) { Dictionary <CmdletModel.UriEnums, string> dictionary = HelperUtils.ParseUri(protectedItems[i].Id); string containerUri = HelperUtils.GetContainerUri(dictionary, protectedItems[i].Id); string protectedItemUri = HelperUtils.GetProtectedItemUri(dictionary, protectedItems[i].Id); var getResponse = ServiceClientAdapter.GetProtectedItem( containerUri, protectedItemUri, getItemQueryParams, vaultName: vaultName, resourceGroupName: resourceGroupName); protectedItemGetResponses.Add(getResponse.Body); } } List <CmdletModel.ItemBase> itemModels = ConversionHelpers.GetItemModelListCrr(protectedItems); if (!string.IsNullOrEmpty(itemName)) { for (int i = 0; i < itemModels.Count; i++) { extendedInfoProcessor(itemModels[i], protectedItemGetResponses[i]); } } return(itemModels); }