public void RemoveServer()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();
                var client = GetSiteRecoveryClient(CustomHttpHandler);

                FabricListResponse responseServers = client.Fabrics.List(RequestHeaders);

                FabricResponse response = client.Fabrics.Get(responseServers.Fabrics[0].Name, RequestHeaders);

                foreach (Fabric fabric in responseServers.Fabrics)
                {
                    var dras = client.RecoveryServicesProvider.List(fabric.Name, RequestHeaders).RecoveryServicesProviders;

                    RecoveryServicesProviderDeletionInput input = new RecoveryServicesProviderDeletionInput()
                    {
                        Properties = new RecoveryServicesProviderDeletionInputProperties()
                    };

                    var removeServerResponse = client.RecoveryServicesProvider.Delete(fabric.Name, dras[0].Name, input, RequestHeaders);
                }

                Assert.NotNull(response.Fabric);
                Assert.NotNull(response.Fabric.Name);
                Assert.NotNull(response.Fabric.Id);
                Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            }
        }
        /// <summary>
        /// Remove Server
        /// </summary>
        private void RemoveServer()
        {
            if ((String.Compare(this.Server.FabricType, Constants.VMM) != 0 && String.Compare(this.Server.FabricType, Constants.HyperVSite) != 0))
            {
                throw new PSInvalidOperationException(Properties.Resources.InvalidServerType);
            }

            LongRunningOperationResponse response;

            if (!this.Force.IsPresent)
            {
                RecoveryServicesProviderDeletionInput input = new RecoveryServicesProviderDeletionInput()
                {
                    Properties = new RecoveryServicesProviderDeletionInputProperties()
                };

                response =
                        RecoveryServicesClient.RemoveAzureSiteRecoveryProvider(Utilities.GetValueFromArmId(this.Server.ID, ARMResourceTypeConstants.ReplicationFabrics), this.Server.Name, input);
            }
            else
            {
                response =
                        RecoveryServicesClient.PurgeAzureSiteRecoveryProvider(Utilities.GetValueFromArmId(this.Server.ID, ARMResourceTypeConstants.ReplicationFabrics), this.Server.Name);
            }

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

            WriteObject(new ASRJob(jobResponse.Job));
        }      
 /// <summary>
 /// Deletes a provider
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.SiteRecovery.IRecoveryServicesProviderOperations.
 /// </param>
 /// <param name='fabricName'>
 /// Required. Name of provider's fabric
 /// </param>
 /// <param name='providerName'>
 /// Required. Provider Name.
 /// </param>
 /// <param name='input'>
 /// Required. Deletion input.
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Optional. Request header parameters.
 /// </param>
 /// <returns>
 /// A standard service response for long running operations.
 /// </returns>
 public static LongRunningOperationResponse BeginDeleting(this IRecoveryServicesProviderOperations operations, string fabricName, string providerName, RecoveryServicesProviderDeletionInput input, CustomRequestHeaders customRequestHeaders)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((IRecoveryServicesProviderOperations)s).BeginDeletingAsync(fabricName, providerName, input, customRequestHeaders);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
 /// <summary>
 /// Deletes a provider
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.SiteRecovery.IRecoveryServicesProviderOperations.
 /// </param>
 /// <param name='fabricName'>
 /// Required. Name of provider's fabric
 /// </param>
 /// <param name='providerName'>
 /// Required. Provider Name.
 /// </param>
 /// <param name='input'>
 /// Required. Deletion input.
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Optional. Request header parameters.
 /// </param>
 /// <returns>
 /// A standard service response for long running operations.
 /// </returns>
 public static Task<LongRunningOperationResponse> BeginDeletingAsync(this IRecoveryServicesProviderOperations operations, string fabricName, string providerName, RecoveryServicesProviderDeletionInput input, CustomRequestHeaders customRequestHeaders)
 {
     return operations.BeginDeletingAsync(fabricName, providerName, input, customRequestHeaders, CancellationToken.None);
 }
 /// <summary>
 /// Remove Azure Site Recovery Providers.
 /// </summary>
 /// <param name="fabricId">Fabric ID</param>
 /// <param name="providerId">Provider ID</param>
 /// <returns>Provider response</returns>
 public LongRunningOperationResponse RemoveAzureSiteRecoveryProvider(string fabricId, string providerId, RecoveryServicesProviderDeletionInput input)
 {
     return this.GetSiteRecoveryClient().RecoveryServicesProvider.BeginDeleting(fabricId, providerId, input, this.GetRequestHeaders());
 }