简体   繁体   English

保持 Azure 自托管代理运行和连接

[英]Keep Azure self-hosted agents running and connected

I have a few questions regarding Azure self-hosting.我有一些关于 Azure 自托管的问题。

Assume a Windows self-hosted agent is set up on a physical machine M by user Alex .假设用户Alex在物理机M上设置了Windows自托管代理。 The agent goes offline when Alex logs off and the machine goes to sleep.Alex注销并且机器进入睡眠状态时,代理会脱机。 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 .现在,当Bob登录到同一台机器时,他必须设置一个不同的代理,而Alex设置的代理仍然处于离线状态,并且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 .我尝试以interactivelyas 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.我们确实有一个Linux集群在运行,因此我们可以避免机器进入睡眠状态的问题,但访问代理仍然是一个问题。 Also, we only have physical machines in our lab to run Windows and macOS , and users have to log out after using them.另外,我们实验室只有物理机来运行WindowsmacOS ,用户使用后必须注销。

Any help would be greatly appreciated!任何帮助将不胜感激!

If on a Windows server that is configured to not go to sleep, create the agent and run as a service.如果在配置为不进入睡眠状态的Windows服务器上,请创建代理并作为服务运行。 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.如果您作为服务运行,则代理无法执行 UI 自动化。 If you need UI-automation to execute on the agent, you will need to run it as an interactive agent.如果您需要在代理上执行 UI 自动化,则需要将其作为交互式代理运行。 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.我们利用 Microsoft 文档中提供的批处理脚本在不影响交互式代理的情况下断开连接。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM