Search code examples
azure-service-fabricazure-powershell

Service Fabric Restart Application


I have a service fabric app that reads from KeyVault on startup. When we change the KeyVault value we have to restart the nodes for it to read the new value. This causes the other applications on the same node to go down.

I am trying to write a PowerShell script to restart the service fabric application I have got the following script working on a 1 node cluster however it does not work on multiple node cluster.

Restart-ServiceFabricDeployedCodePackage -ApplicationName $appName -CommandCompletionMode Verify -ServiceName $ServiceName -TimeoutSec 8000

When I have a multiple node cluster this does not work. I can't figure out why it will not work.

Am I doing something wrong?


Solution

  • The minimum amount of parameters that I made this powershell command work are:

    -ApplicationName -NodeName -ServiceManifestName -CodePackageName -ServicePackageActivationId

    Like this: Restart-ServiceFabricDeployedCodePackage -ApplicationName fabric:/App -NodeName "Node01" -ServiceManifestName "ServicePkg" -CodePackageName "Code" -ServicePackageActivationId xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

    Using this command I sometimes get weird error Did not find deployed code package for fabric:/App:Code on node Node01 but at least every time service gets restarted. I've played with other parameters combinations but with no luck. It seems above parameters are must.

    Writing generic powershell script which restart specific service (and only this service) on all nodes, I would've firstly take all node names running Get-ServiceFabricNode and then iterating on these names run Get-ServiceFabricDeployedCodePackage -NodeName Node01 -ApplicationName fabric:/App -ServiceManifestName ServicePkg in order to take ServicePackageActivationId which is the only parameter that is dynamic. And finally with ServicePackageActivationId run Restart-ServiceFabricDeployedCodePackage