首页 > 解决方案 > Azure DevOps 服务 - 自托管代理已脱机

问题描述

为代理启动 Windows 服务时,事件日志中会记录以下错误:

Failed to create session. VS30063: You are not authorized to access https://dev.azure.com.
(Level: Error; Source: VstsAgentService)

代理使用 PAT 进行配置。Windows 服务作为网络服务运行。配置依据:https ://docs.microsoft.com/en-us/azure/devops/pipelines/agents/v2-windows?view=azure-devops

代理程序已经成功运行了数周,但有些东西破坏了我们的代理程序。当然,它随后会与某种类型的变化相关联。提前感谢任何故障排除提示。

从 中提取Agent_20200421-125954-utc.log

[2020-04-21 12:59:58Z INFO RSAEncryptedFileKeyManager] Loading RSA key parameters from file D:\agent5\.credentials_rsaparams
[2020-04-21 12:59:58Z INFO RSAEncryptedFileKeyManager] Loading RSA key parameters from file D:\agent5\.credentials_rsaparams
[2020-04-21 12:59:58Z INFO VisualStudioServices] AAD Correlation ID for this token request: Unknown
[2020-04-21 12:59:58Z WARN VisualStudioServices] Authentication failed with status code 401.
...
[2020-04-21 12:59:58Z ERR  VisualStudioServices] POST request to https://dev.azure.com/{organization}/_apis/distributedtask/pools/1/sessions is not authorized. Details: VS30063: You are not authorized to access https://dev.azure.com.
[2020-04-21 12:59:58Z ERR  MessageListener] Catch exception during create session.
[2020-04-21 12:59:58Z ERR  MessageListener] Microsoft.VisualStudio.Services.Common.VssUnauthorizedException: VS30063: You are not authorized to access https://dev.azure.com.
[2020-04-21 12:59:58Z INFO MessageListener] Non-retriable exception: VS30063: You are not authorized to access https://dev.azure.com.
[2020-04-21 12:59:58Z ERR  Terminal] WRITE ERROR: Failed to create session. VS30063: You are not authorized to access https://dev.azure.com.

标签: azure-devops-self-hosted-agent

解决方案


有什么东西破坏了我们的特工。

由于完全不知道现在有什么变化以及代理的损坏情况如何,请提供一些可能的建议,您可以尝试一下。

去吧D:\agent5.credentials文字打开。

确保其内容如下所示:

{
  "scheme": "OAuth",
  "data": {
    "clientId": "xxxxxx", # This are generated automatically by     
    "authorizationUrl": "https://vssps.dev.azure.com/{org name}/_apis/oauth2/token",
    "oauthEndpointUrl": "https://vssps.dev.azure.com/{org name}/_apis/oauth2/token"
  }
}

然后保存它,并尝试再次重新运行代理。


如果这种方式仍然无法使您的代理可用,或者文件包含我上面提到的内容,那么现在我猜应该是文件.credentials损坏了。.credentials_rsaparams

.credentials_rsaparams是一个具有 RSA 私钥的文件,用于代理和服务器之间的 OAuth 令牌交换。服务器持有公钥,每 50 分钟服务器会向代理发送一个新的令牌,该令牌由公钥加密。

它是服务器自动生成的文件,这意味着你不能手动修改它,因为你不知道你应该输入什么。

目前,您最好按照以下步骤重新配置此代理:

1)使用Run as Administrator运行Command line/ ,然后.Powershell linecd D:\agent5

2)运行.\config remove。并在删除成功后执行代理配置步骤。


推荐阅读