0
votes

I want to install an azure agent onto my VM and have it appear as an Environment resource as described here: https://docs.microsoft.com/en-us/azure/devops/pipelines/process/environments-virtual-machines?view=azure-devops .

This works if you run the script interactively, however when I use --unattended (as described here: https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/v2-windows?view=azure-devops#unattended-config ) there is no longer a way to specify tags. The --addDeploymentGroupTags option doesn't work with Environment agents.

How do I automate the adding of a VM as an environment resource with tags?

2

2 Answers

1
votes

I had a look at the source code and figured out there is an undocumented way to do this. Just use the following commands:

--addvirtualmachineresourcetags --virtualmachineresourcetags "<tag>"

0
votes

According to the official doc , the “interactive PS registration script” supports to add the environments tags. This document doesn’t mention adding tags in “Unattended config” mode.

You can add tags to the VM as part of the interactive PS registration script. You can also add or remove tags from the resource view by clicking on ... at the end of each VM resource on the Resources tab.

We could simply run .\config.cmd --help to check the help info of this command in PowerShell. Config Command

It only mentions how to add a “deploygroup tag” through an option. Not any info related to tag of VM resource in environment.

I'm afraid this is not available to add tags to Environment VM resource in “Unattended config” mode.