I am developing in Azure Service Fabric and there are several times when the Service Fabric is not started for some reason (usually after a reboot). The Service Fabric Manager in the system tray has horrible response time (if it responds at all).
Is there a PowerShell cmdlet or even a cli command that I can use to start the local Service Fabric?
You can just use the Start-Service
cmdlet
PS C:\windows\system32> Start-Service FabricHostSvc
WARNING: Waiting for service 'Microsoft Service Fabric Host Service (FabricHostSvc)' to start...
You can also check if the host is running by running Get-Service
PS C:\windows\system32> Get-Service FabrichostSvc
Status Name DisplayName
------ ---- -----------
Running FabrichostSvc Microsoft Service Fabric Host Service
If it's running you can also use Restart-Service
PS C:\windows\system32> Restart-Service FabrichostSvc
WARNING: Waiting for service 'Microsoft Service Fabric Host Service (FabrichostSvc)' to start...
WARNING: Waiting for service 'Microsoft Service Fabric Host Service (FabrichostSvc)' to start...
I had a similar issue and ended up using the utility functions provided with the SDK which I found here:
C:\Program Files\Microsoft SDKs\Service Fabric\Tools\Scripts\ClusterSetupUtilities.psm1
In my powershell script I use the following to import the utility functions:
# Import the cluster setup utility module
$sdkInstallPath = (Get-ItemProperty 'HKLM:\Software\Microsoft\Service Fabric SDK').FabricSDKScriptsPath
$modulePath = Join-Path -Path $sdkInstallPath -ChildPath "ClusterSetupUtilities.psm1"
Import-Module $modulePath
Then I have the following to check if the cluster is running and to start it if it is not:
# Start the local cluster if needed
if (-not (IsLocalClusterRunning))
{
StartLocalCluster
}
Under the covers it basically does the same thing that Kevin does in his answer (Start-Service FabricHostSvc
). So if you are setting up a PowerShell script this may be helpful but if you just wanted to run a command in PowerShell it may be cumbersome to import the utilities.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With