function Set-AlkamiServiceFabricApplicationInstanceCount { <# .SYNOPSIS Sets the desired 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 DesiredInstanceCount The desired number of instances to run the service with. .PARAMETER ComputerName The host name of any FAB server in the Service Fabric cluster. #> [CmdletBinding()] Param( [Parameter(Mandatory = $true)] [string]$ServiceFabricApplicationName, [Parameter(Mandatory = $true)] [string]$DesiredInstanceCount, [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"; # Set the service instance count. try { Update-ServiceFabricService -ServiceName $serviceName -InstanceCount $DesiredInstanceCount -Stateless -Force; } catch { Write-Error "$loglead : Failed to set service count for application $ServiceFabricApplicationName. $_"; } }