title: Unabled to deploy service fabric application to azure remote cluster from VSTS continuous inrgration
body: <p>I have configured a CI build for a Service Fabric application, in Visual Studio Team Services, according to this documentation: <a href="https://azure.microsoft.com/en-us/documentation/articles/service-fabric-set-up-continuous-integration" rel="nofollow">https://azure.microsoft.com/en-us/documentation/articles/service-fabric-set-up-continuous-integration</a>.</p>
  
  <p>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:</p>
  
  <p>[void](Connect-ServiceFabricCluster @ClusterConnectionParameters)
  InvalidOperation: (:) [Connect-ServiceFabricCluster], FabricException
  FullyQualifiedErrorId : CreateClusterConnectionErrorId,Microsoft.ServiceFabric.Powershell.ConnectCluster</p>
  
  <p>WARNING: Unable to Verify connection to Service Fabric cluster.</p>
  
  <p>[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</p>
  
  <p>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.</p>
  
  <p>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</p>
  
  <p>This doesn't help either. Thanks in advance for your kind help.</p>