Hello you all,

I have a VM on Azure that I need to connect to the company's VPN as soon as the machine starts, because on that machine runs a TFS agent responsible of performing some company's actions. So a stable VPN connection is needed in order to let TFS see the VM's agent and perform the actions.

What I did is creating a Windows startup schedule which starts the connection, this way:

schtasks /create /tn "ConnectToVPN" /sc onstart /rl highest /ru system /tr "C:\Program Files (x86)\CheckPoint\Endpoint Connect\trac connect -s connectionUrl -u username -p password"
If I restart the VM and DO NOT connect to it via Remote Desktop, TFS founds the agent available, which means that the VPN connection is working as expected. Bingo!

What is strange is that if I connect to the VM via Remote Desktop and then I disconnect from it, the VPN connection disconnects too; I can see this because TFS shows me that the VM agent is not reachable.

This is a strange behavior, because everything works well if I do not connect via Remote Desktop to the VM after the VM reboot, but breaks if I connect and then dsconnect. What is happening? Do you know anything that can cause this issue?