4

I followed the steps to add a VM resource to an environment but got an error when running the script. I searched the error message but couldn't find anything.

Error messaege: Failed to add virtual machine resource. Linked environment pool is null.

The log file has these:

[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

The config command is basically the following:

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

I am the org admin on DevOps and ran the script as server admin on the on-prem VM.

Update

After using the --unattanded option:

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

I got a different error.

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

Update 2

I found others are having the same or similar issues.

Azure Devops Pipeline Environment Resource Agent installation issue

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

Ray Cheng
  • 12,230
  • 14
  • 74
  • 137
  • try to add to the command `--unattended` – Shayki Abramczyk Oct 19 '21 at 08:21
  • I am running into the same issue. I created a new environment from scratch in Azure DevOps, and it worked. I think maybe this is an issue with older environments. – Tim Wilson Oct 22 '21 at 19:10
  • I don't actually I think I needed to add the VM to the existing environment. What I was really trying to accomplish was adding it to a deployment group. Adding it to the deployment group using the generated script in the UI worked around this error and solved my main issue, which was deploying an existing pipeline to new VMs. More details: https://stackoverflow.com/a/59767078/1734757 – Tim Wilson Oct 22 '21 at 19:28
  • @ShaykiAbramczyk After adding `--unattended`, I got a different error: `Flag 'unattended': 'True' Failed to add virtual machine resource. Linked environment pool is null. ` – Ray Cheng Oct 26 '21 at 16:39
  • @RayCheng try to remove the `--pool org-agent-pool-nm` – Shayki Abramczyk Oct 27 '21 at 06:40

1 Answers1

0
  • Look at the Deployment Pool permissions.
  • There you need to have permissions on the pool, where your machine is looking for the pool.
  • If you don't have permissions you will see above issue.
  • Once you got the permissions you are able to see Deployment pool name.