2
votes

I have configured a CI build for a Service Fabric application, in Visual Studio Team Services, according to this documentation: https://azure.microsoft.com/en-us/documentation/articles/service-fabric-set-up-continuous-integration.

However I've changed the deployment portion specified on the document above. As I want to deploy on my previously created remote azure cluster so I call the Deploy-FabricApplication.ps1 with the required parameters using power shell. But unfortunately this is not working. I'm getting the below error:

[void](Connect-ServiceFabricCluster @ClusterConnectionParameters) InvalidOperation: (:) [Connect-ServiceFabricCluster], FabricException FullyQualifiedErrorId : CreateClusterConnectionErrorId,Microsoft.ServiceFabric.Powershell.ConnectCluster

WARNING: Unable to Verify connection to Service Fabric cluster.

[error]Test-ServiceFabricClusterConnection : Cluster connection instance is null [error]At C:\Program Files\Microsoft SDKs\Service [error]Fabric\Tools\PSModule\ServiceFabricSDK\Publish-NewServiceFabricApplication.ps1:119 char:16 void : ResourceUnavailable: (:) [Test-ServiceFabricClusterConnection], NullReferenceException FullyQualifiedErrorId : GetClusterConnectionErrorId,Microsoft.ServiceFabric.Powershell.TestClusterConnection

I can deploy successfully using visual studio. Even if I run the Deploy-FabricApplication.ps1 from the build machine using power shell the application gets deployed without any error. But only if I run it using VSTS build step (part of CI), then the error mentioned above occurs.

Please note that as per the suggestion of Charisk on another stackoverflow thread I've modified the Deploy-FabricApplication.ps1 file to put the below line after line 169. $global:clusterConnection = $clusterConnection

This doesn't help either. Thanks in advance for your kind help.

2
Which task are you using to run the power-shell script? Powershell or Azure Powershell? Did you try the resolution in that thread: Using the "pure" powershell build task made sure that the script was executed using the . (dot) notation which worked like a charm.?Eddie Chen - MSFT
I'm using Powershelluser1814131
I think the problem is regarding with . (dot) notation. I just specified the path for the default Deploy-FabricApplication.ps1 in vsts build task. I also passed some parameters. How can I make sure that the script will be executed using dot notation? I believing invoking is the case in my scenario instead of dot sourcing.user1814131

2 Answers

2
votes

In your publish profile http://s30.postimg.org/bttleqitd/cloud.jpg you use StoreLocation="CurrentUser" but if you followed https://azure.microsoft.com/en-us/documentation/articles/service-fabric-set-up-continuous-integration and specifically the Import your automation certificate section under Set up your build machine then you probably have imported your certificate to the LocalMachine store location.

Simply change StoreLocation in your publish profile from CurrentUser to LocalMachine and you should be good to go.

0
votes

dot source notation means call the script with . "xxx.ps1". Refer to this link for details: PowerShell – What is dot sourcing and why use it?

enter image description here