无法在 Azure DevOps 2019 中通过代码(无权限)创建代理池
Can not create Agent Pool by code (no permissions) at Azure DevOps 2019
我问有关通过 c# 创建代码的问题:。
所以,我的代码是:
var _tfsUrl = "http://mytfs.domain.local:8080/tfs/Collection_Name/";
VssCredentials c = new VssCredentials(new WindowsCredential());
using (var connection= new VssConnection(new Uri(_tfsUrl), c))
{
var client = connection.GetClient<TaskAgentHttpClient>();
var agentPools = client.GetAgentPoolsAsync().Result;
var result = client.AddAgentPoolAsync(new TaskAgentPool("Auto test pool_1")).Result; //error !
}
但是我没有权限:
System.AggregateException: 'Web method running: [http://mytfs.domain.local:8080/tfs/Collection_Name/_apis/distributedtask/pools] (POST)pools[distributedtask] E2EId: some_uid'
AccessDeniedException: Access denied. 'UserName' needs Manage permissions to perform the action. For more information, contact the Azure DevOps Server administrator.
所以,我尝试手动创建代理池并且成功了!
我的用户名在 'Agent Pools-> Security' 中拥有管理权限。
我的角色是:构建管理员、项目管理员、发布管理员。
你能告诉我,如何解决这个问题吗?
谢谢!
您的代码正在尝试在项目集合级别创建代理池。
必须确保您是所有代理池中具有管理员角色的组的成员,方法是导航至代理池您组织设置中的页面。
此外,您还可以尝试在您的代码段中使用您用户的 PAT 令牌(完全访问权限)进行身份验证。
如果上述方法仍然无效,只需将您的用户添加到 'Project Collection Administrators' 组,这应该可以解决问题。
我问有关通过 c# 创建代码的问题:
所以,我的代码是:
var _tfsUrl = "http://mytfs.domain.local:8080/tfs/Collection_Name/";
VssCredentials c = new VssCredentials(new WindowsCredential());
using (var connection= new VssConnection(new Uri(_tfsUrl), c))
{
var client = connection.GetClient<TaskAgentHttpClient>();
var agentPools = client.GetAgentPoolsAsync().Result;
var result = client.AddAgentPoolAsync(new TaskAgentPool("Auto test pool_1")).Result; //error !
}
但是我没有权限:
System.AggregateException: 'Web method running: [http://mytfs.domain.local:8080/tfs/Collection_Name/_apis/distributedtask/pools] (POST)pools[distributedtask] E2EId: some_uid'
AccessDeniedException: Access denied. 'UserName' needs Manage permissions to perform the action. For more information, contact the Azure DevOps Server administrator.
所以,我尝试手动创建代理池并且成功了!
我的用户名在 'Agent Pools-> Security' 中拥有管理权限。
我的角色是:构建管理员、项目管理员、发布管理员。
你能告诉我,如何解决这个问题吗? 谢谢!
您的代码正在尝试在项目集合级别创建代理池。
必须确保您是所有代理池中具有管理员角色的组的成员,方法是导航至代理池您组织设置中的页面。
此外,您还可以尝试在您的代码段中使用您用户的 PAT 令牌(完全访问权限)进行身份验证。
如果上述方法仍然无效,只需将您的用户添加到 'Project Collection Administrators' 组,这应该可以解决问题。