Setting up Azure DevOps agent in Windows Subsystem for Linux

Windows Subsystem for Linux gives us the option to run our favorite Linux Distributions from Windows OS itself, On how to enable it you can see it over here

Let us see how to install an Azure DevOps agent on it and autostart is as a service so that we can use Linux for some of our pipelines.

Installing an Azure DevOps agent in Windows Subsystem for Linux

Step1: Login to the Windows and open your Linux Distribution (In my case it’s ubuntu)

Step2: Now create a folder where you want to have your agent,(Either you can create it somewhere in the home directory or Drivers like C,D, E etc.,) Let us create a directory under the home itself and call it as _AzureDevOpsAgent

You can see more about adding an agent Pool over here

Step 3: Then download the agent as shown

Step 4: Once the agent file has been downloaded, rename it and extract it by these commands

cd _AzureDevOpsAgent
tar zxvf ~/vsts-agent-linux-x64-2.171.1.tar.gz

Step 5:

Step 6: Enter the AzureDevOps url and then the PAT Token, Agent Pool and finally the agent name

Step 7: Then execute the script to run the agent interactively

This shows Agent has started running and you can check the same in AzureDevOps also

Step 8: Go to the Private Agent Pool and check under the agents, you can see the agents we have configured running

Step 9: Though the agent is up and running, it’s running in interactive mode, Since it’s also WSL there are some issues in starting it, so the best way is to make it run is to have a task scheduler and with these commands

"ubuntu.exe run "/home/shan2009/_AzureDevOpsAgent/"

Step 10: Add a task that will be running on the startup as shown such that it runs the agent interactively at the startup

The commands to start the agent will be

ubuntu.exe run "/home/shan2009/_AzureDevOpsAgent/"

Add these commands in the bat file and execute the bat file on System startup under any account name.Now create the task and then restart the system to see whether agent comes online without any manual intervention (This works in almost all the Windows servers)

You may also like...