Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Publish to Service Fabric Cluster fails because of Test-ServiceFabricClusterConnection

I am using the Deploy-FabricApplication.ps1 script that is generated when you create a Service Fabric project to deploy my application.

When deploying to a Service Fabric cluster I can deploy locally if I first connect to a local cluster using Connect-ServiceFabricCluster. However, my build server does not run a local cluster instance so I am unable to first connect to a local instance. When I connect with Connect-ServiceFabricCluster @ClusterConnectionParameters I get data back on the connection that it was successful. When it gets to the publish and runs the Test-ServiceFabricClusterConnection command I get the following error.

WARNING: Unable to Verify connection to Service Fabric cluster.
Test-ServiceFabricClusterConnection : Cluster connection instance is null
At C:\ProgramFiles\MicrosoftSDKs\ServiceFabric\Tools\PSModule\ServiceFabricSDK\Publish-NewServiceFabricApplication.ps1:129 char:16
+         [void](Test-ServiceFabricClusterConnection)
+                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (:) [Test-ServiceFabricClusterConnection], NullReferenceException
    + FullyQualifiedErrorId : GetClusterConnectionErrorId,Microsoft.ServiceFabric.Powershell.TestClusterConnection

I have tried removing Test-ServiceFabricClusterConnection from the Publish-NewServiceFabricApplication.ps1 module and I get a different set of errors. No matter what I have tried to this point, if I first connect to a cluster it works but not if I connect via the powershell script.

Update! Solved Solved this using dot sourcing: How do I deploy service fabric application from VSTS release pipeline?

like image 691
KenWin0x539 Avatar asked Sep 21 '16 19:09

KenWin0x539


1 Answers

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.

like image 198
sysofwan Avatar answered Nov 07 '22 21:11

sysofwan