Share via

IStatefulServiceReplica.ChangeRoleAsync Method


Changes the role of the service replica to one of the ReplicaRole.

public System.Threading.Tasks.Task<string> ChangeRoleAsync (System.Fabric.ReplicaRole newRole, System.Threading.CancellationToken cancellationToken);
abstract member ChangeRoleAsync : System.Fabric.ReplicaRole * System.Threading.CancellationToken -> System.Threading.Tasks.Task<string>
Public Function ChangeRoleAsync (newRole As ReplicaRole, cancellationToken As CancellationToken) As Task(Of String)



The updated ReplicaRole that this replica should transition to.


The CancellationToken object that the operation is observing. It can be used to send a notification that the operation should be canceled. Note that cancellation is advisory and that the operation might still be completed even if it is canceled.


Returns Task<TResult> of type String, the service’s new connection address that is to be associated with the replica via Service Fabric Naming.


The new role is indicated as a parameter. When the service transitions to the new role, the service has a chance to update its current listening address. The listening address is the address where clients connect to it and the one returned via the ResolveAsync API. This enables the service when it is a primary replica to only claim some resources such as ports when communication from clients is expected.

Applies to