How to add Azure DevOps Agent to the environment

Azure DevOps:

Go to Azure DevOps portal and click environment option under pipeline

Create environment, provide the name of your env and hit create.

Once env is created, get into the env and click add resource

Chose Virtual Machines Option

Chose the OS type and copy the commands in the copy dialog which is highlighted

Linux VM:

SSH into your Linux vm and switch to root user

sudo su 

Create a user for Azure DevOps agent to run with required privilege

adduser azure_devops

Once User is created, grant sudo access to the user by

nano /etc/sudoers

Add the line in the file

azure_devops    ALL=(ALL:ALL) NOPASSWD: ALL

Now switch to the newly created user by

sudo su azure_devops

Change the path to user home path

cd /home/azure_devops

Now past and run the command copied from Azure DevOps, the command would be like

mkdir azagent;cd azagent;curl -fkSL -o vstsagent.tar.gz https://vstsagentpackage.azureedge.net/agent/3.241.0/vsts-agent-linux-x64-3.241.0.tar.gz;tar -zxvf vstsagent.tar.gz; if [ -x "$(command -v systemctl)" ]; then ./config.sh --environment --environmentname "My Test Env" --acceptteeeula --agent $HOSTNAME --url https://dev.azure.com/*********/ --work _work --projectname 'Test Pipeline' --auth PAT --token ******************************** --runasservice; sudo ./svc.sh install; sudo ./svc.sh start; else ./config.sh --environment --environmentname "My Test Env" --acceptteeeula --agent $HOSTNAME --url https://dev.azure.com/*********/ --work _work --projectname 'Test Pipeline' --auth PAT --token ***************************; ./run.sh; fi

After running this command it will as Yes or No to add tag, once it is done the agent is up and running and it will be started showing in the Environment Resources.

2 Comments

    • Thank you for your feedback! I’m glad to hear that the post was helpful and that it made a difference for you. It’s great to know that the effort put into researching and presenting this information paid off. If you have any questions or need further details on the topic, feel free to ask. Thanks again for your support!

Leave a Reply

Your email address will not be published. Required fields are marked *