/// <summary>
        /// Helper to configure cloud
        /// </summary>
        private void Dissociate(string targetProtectionContainerId)
        {
            RemoveProtectionContainerMappingInputProperties inputProperties = new RemoveProtectionContainerMappingInputProperties()
            {
                ProviderSpecificInput = new ReplicationProviderContainerUnmappingInput()
            };

            RemoveProtectionContainerMappingInput input = new RemoveProtectionContainerMappingInput()
            {
                Properties = inputProperties
            };

            ProtectionContainerMappingListResponse protectionContainerMappingListResponse = RecoveryServicesClient.GetAzureSiteRecoveryProtectionContainerMapping(Utilities.GetValueFromArmId(PrimaryProtectionContainer.ID, ARMResourceTypeConstants.ReplicationFabrics), PrimaryProtectionContainer.Name);
            ProtectionContainerMapping             protectionContainerMapping             = protectionContainerMappingListResponse.ProtectionContainerMappings.SingleOrDefault(t => (t.Properties.PolicyId.CompareTo(this.Policy.ID) == 0 && t.Properties.TargetProtectionContainerId.CompareTo(targetProtectionContainerId) == 0));

            if (protectionContainerMapping == null)
            {
                throw new Exception("Cloud is not paired");
            }

            LongRunningOperationResponse response = RecoveryServicesClient.UnConfigureProtection(Utilities.GetValueFromArmId(this.PrimaryProtectionContainer.ID, ARMResourceTypeConstants.ReplicationFabrics), this.PrimaryProtectionContainer.Name, protectionContainerMapping.Name, input);

            JobResponse jobResponse =
                RecoveryServicesClient
                .GetAzureSiteRecoveryJobDetails(PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location));

            this.WriteObject(new ASRJob(jobResponse.Job));
        }
Exemple #2
0
        public static LongRunningOperationResponse UnpairClouds(
            this SiteRecoveryManagementClient client,
            Fabric primaryFabric,
            ProtectionContainer primaryContainer,
            string armResourceName)
        {
            ProtectionContainerMapping mapping =
                client.ProtectionContainerMapping.Get(
                    primaryFabric.Name,
                    primaryContainer.Name,
                    armResourceName,
                    GetRequestHeaders()).ProtectionContainerMapping;

            return(client.ProtectionContainerMapping.UnconfigureProtection(
                       primaryFabric.Name,
                       primaryContainer.Name,
                       armResourceName,
                       new RemoveProtectionContainerMappingInput(),
                       GetRequestHeaders()));
        }
Exemple #3
0
 /// <summary>
 ///     Write Protection Container Mapping
 /// </summary>
 /// <param name="protectionContainerMapping"></param>
 private void WriteProtectionContainerMapping(
     ProtectionContainerMapping protectionContainerMapping)
 {
     this.WriteObject(new ASRProtectionContainerMapping(protectionContainerMapping));
 }