Restart-​Service​Fabric​Replica

Restarts a Service Fabric replica to simulate the reopening of a stateful service replica.

Syntax

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

Description

The Restart-ServiceFabricReplica cmdlet simulates a service replica failure by restarting a persisted service replica, closing the replica, and then reopening it. Use this cmdlet to test your service for problems along the replica reopen path. This cmdlet helps simulate the report fault temporary path through client APIs. This cmdlet is only valid for replicas that belong to stateful persisted services.

In order to specify the replica to be restarted 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 service 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.

In some cases, the user may want to restart 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.

Before you perform any operation on a Service Fabric cluster, establish a connection to the cluster by using the Connect-ServiceFabricCluster cmdlet.

Examples

Example 1: Restart a replica

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

This command restarts the replica on Node07 on the specified partition.

Example 2: Restart a primary replica

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

This command restarts a primary replica on the specified partition.

Required Parameters

-NodeName

Specifies the name of a Service Fabric node. The cmdlet restarts 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 for which to restart the replica.

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

Specifies the key of the partition for which the replica is restarted.

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

Indicates that this cmdlet restarts 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 restarts 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 restarts 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 restarts 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 restarts 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 a Service Fabric service.

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 Restart operation to complete.

Type:CompletionMode
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.Uri

Represents the name of a Service Fabric service.

Inputs

System.Guid

Represents the ID of a Service Fabric partition.

Inputs

String

Specifies the name of a Service Fabric node.