Microsoft.Azure.Commands.SiteRecovery.GetAzureRmSiteRecoveryProtectionContainer.GetByFriendlyNameLegacy C# (CSharp) Method

GetByFriendlyNameLegacy() private method

Queries by friendly name.
private GetByFriendlyNameLegacy ( ) : void
return void
        private void GetByFriendlyNameLegacy()
        {
            ProtectionContainerListResponse protectionContainerListResponse;
            bool found = false;

            FabricListResponse fabricListResponse = RecoveryServicesClient.GetAzureSiteRecoveryFabric();

            foreach (Fabric fabric in fabricListResponse.Fabrics)
            {
                // Do not process for fabrictype other than Vmm|HyperVSite 
                if (String.Compare(fabric.Properties.CustomDetails.InstanceType, Constants.VMM) != 0 && String.Compare(fabric.Properties.CustomDetails.InstanceType, Constants.HyperVSite) != 0)
                    continue;

                protectionContainerListResponse =
                RecoveryServicesClient.GetAzureSiteRecoveryProtectionContainer(fabric.Name);

                foreach (
                    ProtectionContainer protectionContainer in
                    protectionContainerListResponse.ProtectionContainers)
                {
                    if (0 == string.Compare(this.FriendlyName, protectionContainer.Properties.FriendlyName, StringComparison.OrdinalIgnoreCase))
                    {
                        var protectionContainerByName = RecoveryServicesClient.GetAzureSiteRecoveryProtectionContainer(fabric.Name, protectionContainer.Name).ProtectionContainer;
                        this.WriteProtectionContainer(protectionContainerByName);

                        found = true;
                        // break; //We can break if we are sure that we have clouds with unique name across fabrics
                    }
                }
            }

            if (!found)
            {
                throw new InvalidOperationException(
                    string.Format(
                    Properties.Resources.ProtectionContainerNotFound,
                    this.FriendlyName,
                    PSRecoveryServicesClient.asrVaultCreds.ResourceName));
            }
        }