当为代理启动windows服务时,事件日志中会记录以下错误:
Failed to create session. VS30063: You are not authorized to access https://dev.azure.com.
(Level: Error; Source: VstsAgentService)
使用PAT配置代理。windows服务作为网络服务运行。配置依据:https://learn.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.
有什么东西破坏了我们的代理。
由于完全不知道现在的变化是什么以及代理是如何崩溃的,只需给出一些可能的建议,您就可以尝试一下
转到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(使用以管理员身份运行,然后使用cd D:agent5
,运行Command line
/Powershell line
。
2(运行.config remove
。并在删除成功后执行代理配置步骤。