PTN
PTN

Reputation: 1692

Keep Azure self-hosted agents running and connected

I have a few questions regarding Azure self-hosting.

Assume a Windows self-hosted agent is set up on a physical machine M by user Alex. The agent goes offline when Alex logs off and the machine goes to sleep. Now, when Bob logs into the same machine, he has to set up a different agent while the agent set up by Alex is still offline and not accessible by Bob. (Please let me know if I got something wrong here)

Is it possible to set up self-hosted agents in a way such that all users can access the same agent, and how can we avoid the issue of the agent going offline when the machine goes to sleep? I tried running the agent both interactively and as a service.

We do have a Linux cluster running so we can avoid the issue of the machine going to sleep, but accessing the agent is still a concern. Also, we only have physical machines in our lab to run Windows and macOS, and users have to log out after using them.

Any help would be greatly appreciated!

Upvotes: 0

Views: 1872

Answers (1)

Matt
Matt

Reputation: 4045

If on a Windows server that is configured to not go to sleep, create the agent and run as a service. I'd recommend creating the agent to run as a domain service account created just for the agent. Logging off the remote server shouldn't impact the state of the agent.

If you run as a service, the agent can not execute UI-automation. If you need UI-automation to execute on the agent, you will need to run it as an interactive agent. I would still run interactively as a domain service account. If someone were to remote into the box with a different account and it is running interactively, the agent would show up as offline. You would need to either restart that server or log in with that agent account then disconnect correctly.

We leverage the batch script provided in the Microsoft documentation for disconnecting without impacting the interactive agent.

for /f "skip=1 tokens=3" %%s in ('query user %USERNAME%') do (
  %windir%\System32\tscon.exe %%s /dest:console
)

Upvotes: 2

Related Questions