How to start local Azure Service Fabric Cluster with PowerShell or CLI
You can just use the Start-Service
cmdlet
PS C:\windows\system32> Start-Service FabricHostSvcWARNING: 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 FabrichostSvcStatus 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 FabrichostSvcWARNING: 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 neededif (-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.