Beispiel #1
0
        /// <summary>
        /// ProcessRecord of the command.
        /// </summary>
        protected override void ProcessRecord()
        {
            try
            {
                RecoveryServicesProviderListResponse recoveryServicesProviderListResponse =
                    RecoveryServicesClient.GetAzureSiteRecoveryProvider(
                        this.Site.Name);

                if (recoveryServicesProviderListResponse.RecoveryServicesProviders.Count != 0)
                {
                    throw new PSInvalidOperationException(Properties.Resources.SiteRemovalWithRegisteredHyperVHostsError);
                }

                FabricDeletionInput input = new FabricDeletionInput()
                {
                    Properties = new FabricDeletionInputProperties()
                };

                LongRunningOperationResponse response =
                    RecoveryServicesClient.DeleteAzureSiteRecoveryFabric(this.Site.Name, input);

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

                WriteObject(new ASRJob(jobResponse.Job));
            }
            catch (Exception exception)
            {
                this.HandleException(exception);
            }
        }
Beispiel #2
0
        /// <summary>
        /// ProcessRecord of the command.
        /// </summary>
        public override void ExecuteSiteRecoveryCmdlet()
        {
            base.ExecuteSiteRecoveryCmdlet();

            RecoveryServicesProviderListResponse recoveryServicesProviderListResponse =
                RecoveryServicesClient.GetAzureSiteRecoveryProvider(
                    this.Site.Name);

            if (recoveryServicesProviderListResponse.RecoveryServicesProviders.Count != 0)
            {
                throw new PSInvalidOperationException(Properties.Resources.SiteRemovalWithRegisteredHyperVHostsError);
            }

            LongRunningOperationResponse response;

            if (!this.Force.IsPresent)
            {
                response =
                    RecoveryServicesClient.DeleteAzureSiteRecoveryFabric(this.Site.Name);
            }
            else
            {
                response =
                    RecoveryServicesClient.PurgeAzureSiteRecoveryFabric(this.Site.Name);
            }

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

            WriteObject(new ASRJob(jobResponse.Job));
        }
        /// <summary>
        /// ProcessRecord of the command.
        /// </summary>
        public override void ExecuteSiteRecoveryCmdlet()
        {
            base.ExecuteSiteRecoveryCmdlet();

            if (ShouldProcess(this.Site.FriendlyName, VerbsCommon.Remove))
            {
                this.WriteWarningWithTimestamp(
                    string.Format(Properties.Resources.CmdletWillBeDeprecatedSoon,
                                  this.MyInvocation.MyCommand.Name,
                                  "Remove-AzureRmSiteRecoveryFabric"));

                RecoveryServicesProviderListResponse recoveryServicesProviderListResponse =
                    RecoveryServicesClient.GetAzureSiteRecoveryProvider(
                        this.Site.Name);

                if (recoveryServicesProviderListResponse.RecoveryServicesProviders.Count != 0)
                {
                    throw new PSInvalidOperationException(
                              Properties.Resources.SiteRemovalWithRegisteredHyperVHostsError);
                }

                LongRunningOperationResponse response;

                if (!this.Force.IsPresent)
                {
                    response =
                        RecoveryServicesClient.DeleteAzureSiteRecoveryFabric(this.Site.Name);
                }
                else
                {
                    response =
                        RecoveryServicesClient.PurgeAzureSiteRecoveryFabric(this.Site.Name);
                }

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

                WriteObject(new ASRJob(jobResponse.Job));
            }
        }
        /// <summary>
        /// ProcessRecord of the command.
        /// </summary>
        public override void ExecuteSiteRecoveryCmdlet()
        {
            base.ExecuteSiteRecoveryCmdlet();

            if (ShouldProcess(this.Fabric.FriendlyName, VerbsCommon.Remove))
            {
                LongRunningOperationResponse response;

                if (!this.Force.IsPresent)
                {
                    response = RecoveryServicesClient.DeleteAzureSiteRecoveryFabric(this.Fabric.Name);
                }
                else
                {
                    response = RecoveryServicesClient.PurgeAzureSiteRecoveryFabric(this.Fabric.Name);
                }

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

                WriteObject(new ASRJob(jobResponse.Job));
            }
        }