Remove-​Service​Fabric​Replica

Removes a replica from a cluster to simulate a replica failure.

Syntax

Remove-ServiceFabricReplica
      [-NodeName] <String>
      [-PartitionId] <Guid>
      [-ReplicaOrInstanceId] <Int64>
      [-CommandCompletionMode <CompletionMode>]
      [-ForceRemove]
      [-TimeoutSec <Int32>]
      [<CommonParameters>]
Remove-ServiceFabricReplica
      [-PartitionId] <Guid>
      [-ReplicaOrInstanceId] <Int64>
      [-CommandCompletionMode <CompletionMode>]
      [-ForceRemove]
      -ServiceName <Uri>
      [-TimeoutSec <Int32>]
      [<CommonParameters>]
Remove-ServiceFabricReplica
      [-PartitionId] <Guid>
      [-CommandCompletionMode <CompletionMode>]
      [-ForceRemove]
      -ServiceName <Uri>
      [-TimeoutSec <Int32>]
      [<CommonParameters>]
Remove-ServiceFabricReplica
      [-PartitionId] <Guid>
      [-CommandCompletionMode <CompletionMode>]
      [-ForceRemove]
      [-ReplicaKindPrimary]
      -ServiceName <Uri>
      [-TimeoutSec <Int32>]
      [<CommonParameters>]
Remove-ServiceFabricReplica
      [-PartitionId] <Guid>
      [-CommandCompletionMode <CompletionMode>]
      [-ForceRemove]
      [-ReplicaKindRandomSecondary]
      -ServiceName <Uri>
      [-TimeoutSec <Int32>]
      [<CommonParameters>]
Remove-ServiceFabricReplica
      [-CommandCompletionMode <CompletionMode>]
      [-ForceRemove]
      -PartitionKey <String>
      [-PartitionKindUniformInt64]
      -ServiceName <Uri>
      [-TimeoutSec <Int32>]
      [<CommonParameters>]
Remove-ServiceFabricReplica
      [-CommandCompletionMode <CompletionMode>]
      [-ForceRemove]
      -PartitionKey <String>
      [-PartitionKindNamed]
      -ServiceName <Uri>
      [-TimeoutSec <Int32>]
      [<CommonParameters>]
Remove-ServiceFabricReplica
      [-CommandCompletionMode <CompletionMode>]
      [-ForceRemove]
      -PartitionKey <String>
      [-PartitionKindNamed]
      [-ReplicaKindRandomSecondary]
      -ServiceName <Uri>
      [-TimeoutSec <Int32>]
      [<CommonParameters>]
Remove-ServiceFabricReplica
      [-CommandCompletionMode <CompletionMode>]
      [-ForceRemove]
      -PartitionKey <String>
      [-PartitionKindUniformInt64]
      [-ReplicaKindRandomSecondary]
      -ServiceName <Uri>
      [-TimeoutSec <Int32>]
      [<CommonParameters>]
Remove-ServiceFabricReplica
      [-CommandCompletionMode <CompletionMode>]
      [-ForceRemove]
      -PartitionKey <String>
      [-PartitionKindNamed]
      [-ReplicaKindPrimary]
      -ServiceName <Uri>
      [-TimeoutSec <Int32>]
      [<CommonParameters>]
Remove-ServiceFabricReplica
      [-CommandCompletionMode <CompletionMode>]
      [-ForceRemove]
      -PartitionKey <String>
      [-PartitionKindUniformInt64]
      [-ReplicaKindPrimary]
      -ServiceName <Uri>
      [-TimeoutSec <Int32>]
      [<CommonParameters>]
Remove-ServiceFabricReplica
      [-ReplicaOrInstanceId] <Int64>
      [-CommandCompletionMode <CompletionMode>]
      [-ForceRemove]
      -PartitionKey <String>
      [-PartitionKindNamed]
      -ServiceName <Uri>
      [-TimeoutSec <Int32>]
      [<CommonParameters>]
Remove-ServiceFabricReplica
      [-ReplicaOrInstanceId] <Int64>
      [-CommandCompletionMode <CompletionMode>]
      [-ForceRemove]
      -PartitionKey <String>
      [-PartitionKindUniformInt64]
      -ServiceName <Uri>
      [-TimeoutSec <Int32>]
      [<CommonParameters>]
Remove-ServiceFabricReplica
      [-CommandCompletionMode <CompletionMode>]
      [-ForceRemove]
      [-PartitionKindSingleton]
      -ServiceName <Uri>
      [-TimeoutSec <Int32>]
      [<CommonParameters>]
Remove-ServiceFabricReplica
      [-CommandCompletionMode <CompletionMode>]
      [-ForceRemove]
      [-PartitionKindSingleton]
      [-ReplicaKindRandomSecondary]
      -ServiceName <Uri>
      [-TimeoutSec <Int32>]
      [<CommonParameters>]
Remove-ServiceFabricReplica
      [-CommandCompletionMode <CompletionMode>]
      [-ForceRemove]
      [-PartitionKindSingleton]
      [-ReplicaKindPrimary]
      -ServiceName <Uri>
      [-TimeoutSec <Int32>]
      [<CommonParameters>]
Remove-ServiceFabricReplica
      [-ReplicaOrInstanceId] <Int64>
      [-CommandCompletionMode <CompletionMode>]
      [-ForceRemove]
      [-PartitionKindSingleton]
      -ServiceName <Uri>
      [-TimeoutSec <Int32>]
      [<CommonParameters>]
Remove-ServiceFabricReplica
      [-CommandCompletionMode <CompletionMode>]
      [-ForceRemove]
      [-ReplicaKindPrimary]
      -ServiceName <Uri>
      [-TimeoutSec <Int32>]
      [<CommonParameters>]
Remove-ServiceFabricReplica
      [-CommandCompletionMode <CompletionMode>]
      [-ForceRemove]
      [-ReplicaKindRandomSecondary]
      -ServiceName <Uri>
      [-TimeoutSec <Int32>]
      [<CommonParameters>]
Remove-ServiceFabricReplica
      [-ReplicaOrInstanceId] <Int64>
      [-CommandCompletionMode <CompletionMode>]
      [-ForceRemove]
      -ServiceName <Uri>
      [-TimeoutSec <Int32>]
      [<CommonParameters>]
Remove-ServiceFabricReplica
      [-CommandCompletionMode <CompletionMode>]
      [-ForceRemove]
      -ServiceName <Uri>
      [-TimeoutSec <Int32>]
      [<CommonParameters>]

Description

The Remove-ServiceFabricReplica cmdlet simulates a Service Fabric replica failure by removing a replica from a Service Fabric cluster. The removal closes the replica, transitions the replica to the role None, and then removes all of the state information of the replica from the cluster. This cmdlet tests the replica state removal path, and simulates the report fault permanent path through client APIs.

In order to specify the replica to be removed we can start either with the node name or the service name.

Then we need to specify the partition to which the replica belongs. We can specify the partition either by specifying the pair (naming scheme, partition key) or by specifying the partition ID. For more details on Microsoft Azure Service Fabric partitioning, please refer to the Partition Service Fabric reliable services article.

Lastly, we may need to specify which replica of the partition we are referring to and that can be done either by specifying the replica role (primary or secondary replica) or by specifying the replica ID.

Note, sometimes the user may - instead of exactly specifying the replica - want to remove say one of the secondaries of a particular partition of a particular service; that is why, some of the forms of the Remove-ServiceFabricReplica cmdlet intentionally leaves some ambiguity about which replica the user is referring -- in these cases, the cmdlet makes some random choices for the user. For example, if the user only provides the service name to the cmdlet, the Remove-ServiceFabricReplica cmdlet will assume that the user means to remove any one of the replicas from any one of the partitions belonging to the service; so it will choose one of the partitions of the service at random and will choose one of the replicas (could be primary or secondary) of the chosen partition at random and will remove that replica.

Examples

Example 1: Remove a replica

PS C:\> Remove-ServiceFabricReplica -NodeName "Node07" -PartitionId 869dd2e9-fdda-42a5-ad96-4b71c795dfd3 -ReplicaOrInstanceId 12345098480948

Before you perform any operation on a Service Fabric cluster, establish a connection to the cluster by using the Connect-ServiceFabricCluster cmdlet. This command removes a replica that belongs to the specified partition that is deployed on the specified node.

Example 2: Remove a primary replica

PS C:\> Remove-ServiceFabricReplica -ReplicaKindPrimary -PartitionKindNamed -PartitionKey "Partition1" -ServiceName fabric:/App/Service

This command removes the primary replica that belongs to a specified named partition.

Required Parameters

-NodeName

Specifies the name of a Service Fabric node. The cmdlet removes a replica deployed on the node that you specify.

Type:String
Position:1
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-PartitionId

Specifies the ID of the partition from which to remove the replica.

Type:Guid
Position:2
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-PartitionKey

Specifies the partition key.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-PartitionKindNamed

Indicates that this cmdlet removes a replica on a named partition.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-PartitionKindSingleton

Indicates that this cmdlet removes a replica on a singleton partition.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-PartitionKindUniformInt64

Indicates that this cmdlet removes a replica on a UniformInt64 partition.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-ReplicaKindPrimary

Indicates that this cmdlet removes the replica for the primary replica.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-ReplicaKindRandomSecondary

Indicates that this cmdlet removes a replica for a random secondary replica.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-ReplicaOrInstanceId

Specifies a Service Fabric service replica or instance ID.

Type:Int64
Position:3
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-ServiceName

Specifies the name of the service to remove.

Type:Uri
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

Optional Parameters

-CommandCompletionMode

Specifies whether the action waits for the remove operation to complete.

Type:CompletionMode
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-ForceRemove

Indicates that this cmdlet forces removal of the replica.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-TimeoutSec

Specifies the time-out period, in seconds, for the operation.

Type:Int32
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

Inputs

System.Guid

This cmdlet accepts the ID of a Service Fabric partition.

Inputs

String

This cmdlet accepts the name of a Service Fabric node.

Inputs

System.Uri

This cmdlet accepts the name of a Service Fabric service.

Outputs

System.Object

This cmdlet returns a System.Fabric.Result.RemoveReplicaResult object that represents the operation result.