Restart stateful Service fabric application

378 views Asked by At

How can I restart a service fabric stateful service, actually its an actor service. I want to get this working locally. Note that this is a local instance.

I've tried the following powershell command

Restart-ServiceFabricReplica -ServiceName fabric:/MyNameSpace.Dashboard.SfApp

but I get this error

Restart-ServiceFabricReplica : Cluster connection instance is null
At line:1 char:1
+ Restart-ServiceFabricReplica -ServiceName fabric:/MyNameSpace.Da ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (:) [Restart-ServiceFabricReplica], NullReferenceException
    + FullyQualifiedErrorId : GetClusterConnectionErrorId,Microsoft.ServiceFabric.Powershell.RestartReplica

I've also tried this but don't know whats going on with this long syntax one, again same error though.

Restart-ServiceFabricDeployedCodePackage -ApplicationName fabric:/MyNameSpace.Dashboard.SfApp -NodeName "_Node_0" -ServiceManifestName "ServicePkg" -CodePackageName "Code" -ServicePackageActivationId 57f2ae77-6478-4f5d-af10-033bd4e4b4fa
1

There are 1 answers

0
Andrew On BEST ANSWER

I managed to get this working with an error that I later found is expected!

I firstly hadn't connected to the instance!

Connect-ServiceFabricCluster -ConnectionEndpoint "localhost:19000"

I then ran this command

Restart-ServiceFabricDeployedCodePackage -NodeName "_Node_0" -ApplicationName fabric:/MyNamespace.Dashboard.SfApp -ServiceManifestName "MyNamespace.Dashboard.ActorsPkg" -CodePackageName "Code"

In most cases the above command seems to error, but it doesn't really fail to restart. Its something to do with having just restarted the service with said command (found someone explain in the comments here Service Fabric Restart Application)

I didn't need to provide the ServicePackageActivationId parameter but if you needed that you could run this command to find out

Get-ServiceFabricDeployedServicePackage -NodeName "_Node_0" -ApplicationName fabric:/MyNamespace.Dashboard.SfApp -ServiceManifestName "MyNamespace.Dashboard.ActorsPkg"

You can also do this within service fabric management portal

enter image description here