无法将 VM 资源添加到 Azure DevOps 环境。

5

我按照步骤将虚拟机资源添加到一个环境中,但在运行脚本时出现了错误。我搜索了错误信息,但没有找到任何东西。

错误消息:Failed to add virtual machine resource. Linked environment pool is null.

日志文件包含以下内容:

[2021-10-18 23:03:25Z ERR  VisualStudioServices] POST request to https://dev.azure.com/xxx/guid/_apis/pipelines/environments/3/providers/virtualmachines failed. HTTP Status: InternalServerError, AFD Ref: Ref A: guid Ref B: WSTEDGE0610 Ref C: 2021-10-18T23:03:25Z
[2021-10-18 23:03:25Z INFO CommandSettings] Flag 'unattended': 'False'
[2021-10-18 23:03:25Z ERR  Terminal] WRITE ERROR (exception):
[2021-10-18 23:03:25Z ERR  Terminal] Microsoft.TeamFoundation.DistributedTask.WebApi.VirtualMachineResourceLinkedPoolNullException: Failed to add virtual machine resource. Linked environment pool is null. 
   at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.HandleResponseAsync(HttpResponseMessage response, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.SendAsync(HttpRequestMessage message, HttpCompletionOption completionOption, Object userState, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.SendAsync[T](HttpRequestMessage message, Object userState, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.SendAsync[T](HttpMethod method, IEnumerable`1 additionalHeaders, Guid locationId, Object routeValues, ApiResourceVersion version, HttpContent content, IEnumerable`1 queryParameters, Object userState, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.Services.Agent.Listener.Configuration.EnvironmentVMResourceConfigProvider.AddAgentAsync(AgentSettings agentSettings, TaskAgent agent, CommandSettings command)
   at Microsoft.VisualStudio.Services.Agent.Listener.Configuration.ConfigurationManager.ConfigureAsync(CommandSettings command)
[2021-10-18 23:03:25Z ERR  Terminal] WRITE ERROR: Failed to add the agent.  Try again or ctrl-c to quit

config命令基本上如下:

config --environment --environmentname DEV --agent computername --runasservice --work _work --url https://dev.azure.com/xxx/ --projectname myprojectname --auth PAT --token xxx

我是DevOps的org管理员,并作为本地虚拟机上的服务器管理员运行脚本。

更新

使用--unattanded选项后:

config --unattanded --disableloguploads --environment --environmentname DEV --pool org-agent-pool-nm --agent computername --runasservice --windowsLogonAccount xxx --windowsLogonPassword xxx --work _work --url https://dev.azure.com/xxx/ --projectname myprojectname --auth PAT --token xxx

我得到了不同的错误。

Flag 'unattended': 'True' 
Failed to add virtual machine resource. Linked environment pool is null. 

更新2

我发现其他人也遇到了相同或类似的问题。

Azure Devops管道环境资源代理安装问题

https://developercommunity.visualstudio.com/t/addition-of-resource-to-environment-fails-for-user/1048111


尝试在命令中添加“--unattended”。 - Shayki Abramczyk
我遇到了同样的问题。我在Azure DevOps中从头开始创建了一个新的环境,它起作用了。我认为这可能是旧环境的问题。 - Tim Wilson
我其实并不认为我需要将虚拟机添加到现有环境中。我真正想要做的是将它添加到一个部署组中。使用界面生成的脚本将其添加到部署组可以解决这个错误,并解决了我的主要问题,即将现有流水线部署到新的虚拟机。更多详情请参考:https://dev59.com/VVIH5IYBdhLWcg3wZtfI#59767078 - Tim Wilson
@ShaykiAbramczyk 在添加了 --unattended 后,我得到了一个不同的错误: Flag 'unattended': 'True' 无法添加虚拟机资源。链接的环境池为空。 - Ray Cheng
@RayCheng 试着移除 --pool org-agent-pool-nm - Shayki Abramczyk
1个回答

0
查看部署池权限。 在那里,您需要对包含您的机器所在的池子具有权限。 如果没有权限,您将看到上述问题。 一旦获得了权限,您就能够看到部署池的名称。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接