Publish to Service Fabric Cluster fails because of Test-ServiceFabricClusterConnection
Set $global:clusterConnection = $clusterConnection
after calling Connect-ServiceFabricCluster
or call Deploy-FabricApplication.ps1
using the dot source notation.
The call to Connect-ServiceFabricCluster
sets a $clusterConnection
variable on the local Powershell scope, which gets lost when calling other scopes. See this post for more information.
Please check the certificate is installed correctly on your machine. I faced similar issue and installed the certificate and it worked. Also verify the store location is correctly set to
StoreLocation="LocalMachine"
if you installed certificate on local machine else set it to StoreLocation="CurrentUser"
For me, it was changing from $clusterConnection = Connect-ServiceFabricCluster -ConnectionEndpoint $ClusterConnectionParameters.ConnectionEndpoint -ErrorAction Stop
to
Connect-ServiceFabricCluster -ConnectionEndpoint $ClusterConnectionParameters.ConnectionEndpoint -ErrorAction Stop