Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to start local Azure Service Fabric Cluster with PowerShell or CLI

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?

like image 269
Tom Padilla Avatar asked Feb 28 '17 13:02

Tom Padilla


2 Answers

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...
like image 156
Kevin Smith Avatar answered Nov 15 '22 22:11

Kevin Smith


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.

like image 20
bygrace Avatar answered Nov 15 '22 22:11

bygrace