Restart-​Service​Fabric​Node

Restarts a Service Fabric node to simulate a cluster node failure.

Syntax

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

Description

The Restart-ServiceFabricNode cmdlet restarts a Service Fabric node by restarting the Fabric.exe process that hosts the node. This cmdlet simulates Service Fabric node failures in the cluster, which tests the failover recovery paths of your service. For more information, see Using test actions (https://docs.microsoft.com/azure/service-fabric/service-fabric-testability-actions).

The Service Fabric node to be restarted can specified in the following ways:

  • Specify node name and optionally the node instance ID.
  • Specify a stateful service replica or stateless service instance and let the cmdlet identify and restart the node that hosts it. The folowing implicit behaviors for replica/instance selection are worth noting:
    • If the service does not use a Singleton partition and neither the PartitionId nor PartitionKey parameter is specified, then the cmdlet picks a partition randomly.
    • If the service is a stateful service and none of the Primary, RandomSecondary and ReplicaOrInstanceId parameters are specified, then the cmdlet randomly picks a replica, regardless of its role.
    • If the service is a stateless service and the ReplicaOrInstanceId parameter is not specified, then the cmdlet randomly picks an instance.

      If you specify a non-zero value for the NodeInstanceId parameter, that ID is compared with the active node ID. If the IDs do not match, the process is not restarted and an error occurs. A stale message can cause this error.

      If you specify the CreateFabricDump parameter, this cmdlet causes the Fabric.exe process to crash on the specified node during restart. This crash creates a process dump for Fabric.exe.

      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 node that hosts a primary replica

PS C:\> Restart-ServiceFabricNode -ReplicaKindPrimary -PartitionKindNamed -PartitionKey "Partition3" -CommandCompletionMode Verify

This command restarts the node that hosts the primary replica of the partition named Partition3. Because the CommandCompletionMode parameter is specified with a value of Verify, the command waits for the target node to restart before it completes.

Example 2: Restart a specified node

PS C:\> Restart-ServiceFabricNode -NodeName "Node01" -CommandCompletionMode DoNotVerify

This command restarts the node named Node01. Because the CommandCompletionMode parameter is specified with a value of DoNotVerify, the command does not wait for the node to restart before it completes.

Required Parameters

-NodeName

Specifies the name of a Service Fabric node. The cmdlet restarts the node that you specify.

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

Specifies the partition ID of a Service Fabric service partition. The cmdlet restarts a node that hosts a replica or instance of this partition.

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

Specifies a partition key for a Service Fabric service partition. The cmdlet identifies the partition that this partition key maps to and restarts a node that hosts a replica or instance of that partition..

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

Indicates that the PartitionKey parameter specifies a partition key for a service that uses Named partitioning scheme.

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

Indicates that the service specified in the ServiceName parameter uses a Singleton partition.

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

Indicates that the PartitionKey parameter specifies a partition key for a service that uses UniformInt64 partitioning scheme.

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

Indicates that this cmdlet restarts the node that hosts the primary replica of the specified partition.

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

Indicates that this cmdlet restarts the node that hosts a random secondary replica of the specified partition.

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

Specifies a Service Fabric service replica or instance ID. The cmdlet restarts the node that hosts the specified replica or instance.

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

Specifies the name of a Service Fabric service. The cmdlet restarts a node that hosts a replica or instance of this 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 to complete. Specify Verify to make the cmdlet wait for restart to complete, and DoNotVerify to make the cmdlet return without waiting for restart to complete.

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

Indicates that a process dump should be created for Fabric.exe on specified node.

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

Specifies a node instance ID. Unless you specify 0, the node instance ID that you specify must match the currently running node. To obtain node instance IDs, run Get-ServiceFabricNode for the target node. For example, for the node N0050, the command Get-ServiceFabricNode -NodeName "N0050" returns a Node object that contains the node instance ID

Type:BigInteger
Position:2
Default value:None
Accept pipeline input:True (ByPropertyName)
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.

Outputs

System.Object

This cmdlet returns a System.Fabric.Testability.RestartNodeResult object that represents the operation result.