1

I have a service fabric application that I want to deploy through VSTS to the one of my VMs. The on-premise cluster I've created there is secured by the certificate. When I connect to the cluster I must use the domain mydomain.net otherwise connection won't be successful. So from my computer using powershell I connect like this:

Connect-ServiceFabricCluster -ConnectionEndpoint mydomain.net:19000 -X509Credential -ServerCertThumbprint [thumb] -FindType FindByThumbprint -FindValue [thumb] -StoreLocation CurrentUser -StoreName My

mydomain.net is a private domain so to tell my computer what this address means I modified hosts file:

[public ip address of cluster VM] mydomain.net

Thanks to this modification my computer knows what mydomain.net actually means and I can connect to the cluster.

Now I want to achieve the same on VSTS using hosted agent. Is there a way to tell hosted agent that mydomain.net is actually some public ip? Because when I use public ip directly in the cluster connection endpoint, the cluster does not let me in:

##[error]Failed to authenticate server identity

SteppingRazor
  • 1,222
  • 1
  • 9
  • 25

1 Answers1

1

Add PowerShell task:

$file = "$env:windir\System32\drivers\etc\hosts"
"[public ip address of cluster VM] mydomain.net" | Add-Content -PassThru $file
Get-Content -Path $file
SteppingRazor
  • 1,222
  • 1
  • 9
  • 25
starian chen-MSFT
  • 33,174
  • 2
  • 29
  • 53
  • Hello. But where? Before the deployment task on VSTS? – SteppingRazor May 22 '18 at 13:36
  • @SteppingRazor Yes, before service fabric application. – starian chen-MSFT May 23 '18 at 01:39
  • Just to keep in mind, if you are not using hosted agent and do that as a task while deploying your service, you will end up with a always growing hosts file, I think this command should be executed only once in this case – Diego Mendes May 28 '18 at 17:31
  • @DiegoMendes Just a sample, you can modify it to check whether the necessary items are existing or not, then do other things. – starian chen-MSFT May 29 '18 at 01:33
  • @DiegoMendes Yes. I specifically asked about hosted agent, I was not aware you can run powershell script on the hosted agent this way. With your private build machine you can go there, change the hosts manually and forget about it. – SteppingRazor May 29 '18 at 08:12
  • 1
    Was just a TIP, some people might copy and past without worrying about the side effects. – Diego Mendes May 29 '18 at 08:27