function Get-AlkamiServiceFabricApplicationInstanceCount { <# .SYNOPSIS Returns the currently running instance count of a microservice. The function fails if the service is not deployed. .PARAMETER ServiceFabricApplicationName The Service Fabric application name of the package to look up. .PARAMETER ComputerName The host name of any FAB server in the Service Fabric cluster. #> [CmdletBinding()] Param( [Parameter(Mandatory = $true)] [string]$ServiceFabricApplicationName, [Parameter(Mandatory = $false)] [Alias("server")] [string]$ComputerName = "localhost" ) $loglead = (Get-LogLeadName); Connect-AlkamiServiceFabricCluster -Hostname $ComputerName; # Locate the service fabric partition for the running application. $serviceName = "$ServiceFabricApplicationName/svc"; $partition = $null; try { $partition = Get-ServiceFabricPartition -ServiceName $serviceName; } catch { throw "$loglead : Failed to locate Service Fabric partition for service $($ServiceFabricApplicationName): $_"; } # Return the instance count of the partition. return $partition.InstanceCount; }