private void GetByNameLegacy()
{
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.Name, protectionContainer.Name, 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.Name,
PSRecoveryServicesClient.asrVaultCreds.ResourceName));
}
}