Share via


Remove-ServiceFabricReplica

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

Syntax

ByNodeName

Remove-ServiceFabricReplica
    [-NodeName] <String>
    [-PartitionId] <Guid>
    [-ReplicaOrInstanceId] <Int64>
    [-ForceRemove]
    [-CommandCompletionMode <CompletionMode>]
    [-TimeoutSec <Int32>]
    [<CommonParameters>]

PartitionId

Remove-ServiceFabricReplica
    [-PartitionId] <Guid>
    -ServiceName <Uri>
    [-ForceRemove]
    [-CommandCompletionMode <CompletionMode>]
    [-TimeoutSec <Int32>]
    [<CommonParameters>]

PartitionIdReplicaPrimary

Remove-ServiceFabricReplica
    [-PartitionId] <Guid>
    -ServiceName <Uri>
    [-ForceRemove]
    [-ReplicaKindPrimary]
    [-CommandCompletionMode <CompletionMode>]
    [-TimeoutSec <Int32>]
    [<CommonParameters>]

PartitionIdReplicaRandomSecondary

Remove-ServiceFabricReplica
    [-PartitionId] <Guid>
    -ServiceName <Uri>
    [-ForceRemove]
    [-ReplicaKindRandomSecondary]
    [-CommandCompletionMode <CompletionMode>]
    [-TimeoutSec <Int32>]
    [<CommonParameters>]

PartitionIdReplicaId

Remove-ServiceFabricReplica
    [-PartitionId] <Guid>
    [-ReplicaOrInstanceId] <Int64>
    -ServiceName <Uri>
    [-ForceRemove]
    [-CommandCompletionMode <CompletionMode>]
    [-TimeoutSec <Int32>]
    [<CommonParameters>]

ServiceName

Remove-ServiceFabricReplica
    -ServiceName <Uri>
    [-ForceRemove]
    [-CommandCompletionMode <CompletionMode>]
    [-TimeoutSec <Int32>]
    [<CommonParameters>]

ServiceNamePartitionSingleton

Remove-ServiceFabricReplica
    -ServiceName <Uri>
    [-ForceRemove]
    [-PartitionKindSingleton]
    [-CommandCompletionMode <CompletionMode>]
    [-TimeoutSec <Int32>]
    [<CommonParameters>]

ServiceNamePartitionNamed

Remove-ServiceFabricReplica
    -ServiceName <Uri>
    -PartitionKey <String>
    [-ForceRemove]
    [-PartitionKindNamed]
    [-CommandCompletionMode <CompletionMode>]
    [-TimeoutSec <Int32>]
    [<CommonParameters>]

ServiceNamePartitionUniformedInt

Remove-ServiceFabricReplica
    -ServiceName <Uri>
    -PartitionKey <String>
    [-ForceRemove]
    [-PartitionKindUniformInt64]
    [-CommandCompletionMode <CompletionMode>]
    [-TimeoutSec <Int32>]
    [<CommonParameters>]

ServiceNamePartitionSingletonReplicaRandomSecondary

Remove-ServiceFabricReplica
    -ServiceName <Uri>
    [-ForceRemove]
    [-PartitionKindSingleton]
    [-ReplicaKindRandomSecondary]
    [-CommandCompletionMode <CompletionMode>]
    [-TimeoutSec <Int32>]
    [<CommonParameters>]

ServiceNamePartitionNamedReplicaRandomSecondary

Remove-ServiceFabricReplica
    -ServiceName <Uri>
    -PartitionKey <String>
    [-ForceRemove]
    [-PartitionKindNamed]
    [-ReplicaKindRandomSecondary]
    [-CommandCompletionMode <CompletionMode>]
    [-TimeoutSec <Int32>]
    [<CommonParameters>]

ServiceNamePartitionUniformedIntReplicaRandomSecondary

Remove-ServiceFabricReplica
    -ServiceName <Uri>
    -PartitionKey <String>
    [-ForceRemove]
    [-PartitionKindUniformInt64]
    [-ReplicaKindRandomSecondary]
    [-CommandCompletionMode <CompletionMode>]
    [-TimeoutSec <Int32>]
    [<CommonParameters>]

ServiceNamePartitionSingletonReplicaPrimary

Remove-ServiceFabricReplica
    -ServiceName <Uri>
    [-ForceRemove]
    [-PartitionKindSingleton]
    [-ReplicaKindPrimary]
    [-CommandCompletionMode <CompletionMode>]
    [-TimeoutSec <Int32>]
    [<CommonParameters>]

ServiceNamePartitionNamedReplicaPrimary

Remove-ServiceFabricReplica
    -ServiceName <Uri>
    -PartitionKey <String>
    [-ForceRemove]
    [-PartitionKindNamed]
    [-ReplicaKindPrimary]
    [-CommandCompletionMode <CompletionMode>]
    [-TimeoutSec <Int32>]
    [<CommonParameters>]

ServiceNamePartitionUniformedIntReplicaPrimary

Remove-ServiceFabricReplica
    -ServiceName <Uri>
    -PartitionKey <String>
    [-ForceRemove]
    [-PartitionKindUniformInt64]
    [-ReplicaKindPrimary]
    [-CommandCompletionMode <CompletionMode>]
    [-TimeoutSec <Int32>]
    [<CommonParameters>]

ServiceNamePartitionSingletonReplicaId

Remove-ServiceFabricReplica
    [-ReplicaOrInstanceId] <Int64>
    -ServiceName <Uri>
    [-ForceRemove]
    [-PartitionKindSingleton]
    [-CommandCompletionMode <CompletionMode>]
    [-TimeoutSec <Int32>]
    [<CommonParameters>]

ServiceNamePartitionNamedReplicaId

Remove-ServiceFabricReplica
    [-ReplicaOrInstanceId] <Int64>
    -ServiceName <Uri>
    -PartitionKey <String>
    [-ForceRemove]
    [-PartitionKindNamed]
    [-CommandCompletionMode <CompletionMode>]
    [-TimeoutSec <Int32>]
    [<CommonParameters>]

ServiceNamePartitionUniformedIntReplicaId

Remove-ServiceFabricReplica
    [-ReplicaOrInstanceId] <Int64>
    -ServiceName <Uri>
    -PartitionKey <String>
    [-ForceRemove]
    [-PartitionKindUniformInt64]
    [-CommandCompletionMode <CompletionMode>]
    [-TimeoutSec <Int32>]
    [<CommonParameters>]

ServiceNameReplicaPrimary

Remove-ServiceFabricReplica
    -ServiceName <Uri>
    [-ForceRemove]
    [-ReplicaKindPrimary]
    [-CommandCompletionMode <CompletionMode>]
    [-TimeoutSec <Int32>]
    [<CommonParameters>]

ServiceNameReplicaRandomSecondary

Remove-ServiceFabricReplica
    -ServiceName <Uri>
    [-ForceRemove]
    [-ReplicaKindRandomSecondary]
    [-CommandCompletionMode <CompletionMode>]
    [-TimeoutSec <Int32>]
    [<CommonParameters>]

ServiceNameReplicaId

Remove-ServiceFabricReplica
    [-ReplicaOrInstanceId] <Int64>
    -ServiceName <Uri>
    [-ForceRemove]
    [-CommandCompletionMode <CompletionMode>]
    [-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 (/azure/service-fabric/service-fabric-concepts-partitioning) 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.

In some cases, the user may want to remove a random partition/replica combination for a service instead of a specific one. This is useful for testability of your services when you want to run through a random set of transitions for your services to simulate real world failures. For example, if you provide only the service name to this cmdlet and leave out the partition and/or the replica information the cmdlet will make a choice at random to select a partition and a replica to fault. Please note the selected partition or replica will only belong to the specified service.

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.

Parameters

-CommandCompletionMode

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

Parameter properties

Type:CompletionMode
Default value:None
Accepted values:Invalid, DoNotVerify, Verify
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ForceRemove

Indicates that this cmdlet forces removal of the replica. By using ForceRemove, we skip the replica shutdown sequence and the replica is removed ungracefully. For stateful service replica, its persistent state would not be cleaned. To check if replicas are present, use Get-ServiceFabricReplica.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-NodeName

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

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ByNodeName
Position:0
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-PartitionId

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

Parameter properties

Type:Guid
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ByNodeName
Position:1
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
PartitionId
Position:1
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
PartitionIdReplicaPrimary
Position:1
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
PartitionIdReplicaRandomSecondary
Position:1
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
PartitionIdReplicaId
Position:1
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-PartitionKey

Specifies the partition key.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ServiceNamePartitionNamed
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionUniformedInt
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionNamedReplicaRandomSecondary
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionUniformedIntReplicaRandomSecondary
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionNamedReplicaPrimary
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionUniformedIntReplicaPrimary
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionNamedReplicaId
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionUniformedIntReplicaId
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-PartitionKindNamed

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

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ServiceNamePartitionNamed
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionNamedReplicaRandomSecondary
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionNamedReplicaPrimary
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionNamedReplicaId
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-PartitionKindSingleton

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

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ServiceNamePartitionSingleton
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionSingletonReplicaRandomSecondary
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionSingletonReplicaPrimary
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionSingletonReplicaId
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-PartitionKindUniformInt64

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

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ServiceNamePartitionUniformedInt
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionUniformedIntReplicaRandomSecondary
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionUniformedIntReplicaPrimary
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionUniformedIntReplicaId
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-ReplicaKindPrimary

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

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

PartitionIdReplicaPrimary
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionSingletonReplicaPrimary
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionNamedReplicaPrimary
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionUniformedIntReplicaPrimary
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNameReplicaPrimary
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-ReplicaKindRandomSecondary

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

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

PartitionIdReplicaRandomSecondary
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionSingletonReplicaRandomSecondary
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionNamedReplicaRandomSecondary
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionUniformedIntReplicaRandomSecondary
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNameReplicaRandomSecondary
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-ReplicaOrInstanceId

Specifies a Service Fabric service replica or instance ID.

Parameter properties

Type:Int64
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ByNodeName
Position:2
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
PartitionIdReplicaId
Position:2
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionSingletonReplicaId
Position:2
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionNamedReplicaId
Position:2
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionUniformedIntReplicaId
Position:2
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNameReplicaId
Position:2
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-ServiceName

Specifies the name of the service to remove.

Parameter properties

Type:Uri
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

PartitionId
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
PartitionIdReplicaPrimary
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
PartitionIdReplicaRandomSecondary
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
PartitionIdReplicaId
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceName
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionSingleton
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionNamed
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionUniformedInt
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionSingletonReplicaRandomSecondary
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionNamedReplicaRandomSecondary
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionUniformedIntReplicaRandomSecondary
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionSingletonReplicaPrimary
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionNamedReplicaPrimary
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionUniformedIntReplicaPrimary
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionSingletonReplicaId
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionNamedReplicaId
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNamePartitionUniformedIntReplicaId
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNameReplicaPrimary
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNameReplicaRandomSecondary
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ServiceNameReplicaId
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-TimeoutSec

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

Parameter properties

Type:Int32
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

System.String

System.Guid

System.Uri

System.Management.Automation.SwitchParameter

System.Nullable`1

Outputs

System.Object