ServiceFabric deployment. Modify hosts on hosted agent

452 Views Asked by At

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

1

There are 1 best solutions below

6
On BEST ANSWER

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