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.
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
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.
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.
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.
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
-CreateFabricDump
Indicates that a process dump should be created for Fabric.exe on specified node.
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
-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.
Parameter properties
Type:
BigInteger
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
ByNodeName
Position:
1
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
True
Value from remaining arguments:
False
-NodeName
Specifies the name of a Service Fabric node.
The cmdlet restarts 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 partition ID of a Service Fabric service partition. The cmdlet restarts a node that hosts a replica or instance of this partition.
Parameter properties
Type:
Guid
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
-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..
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.