How to Configure a Proxy for Your Azure DevOps Build Agent

All of a sudden, our build agent could no longer communicate with Azure. A failed network change forced us to set a proxy server manually. While most browsers use the system proxy, the build agent did not.

For the build agent you need to create a .proxy file with the proxy URL in the root directory of your agent. Let us look how you can do that.

  1. Locate the root directory of your build agent (this is the folder that contains the run.exe and the _work folder).
  2. Open a Command Prompt at this location.
  3. Type this command, but replace PROXYIP & PORT with your values:

    echo https://PROXYIP:PORT > .proxy
    
  4. Check that your .proxy file is created at the right place:
    .proxy must be in same folder as _work and run.exe

  5. Optional: If your proxy needs authentication, you must set these environment variables:

    set VSTS_HTTP_PROXY_USERNAME=user
    set VSTS_HTTP_PROXY_PASSWORD=password
    
  6. Restart the service for your build agent.

Your build agent should now connect to Azure and work as expected.

When you know that you need a proxy at the time of the installation, you can configure the proxy settings right when you call config.cmd:

./config.cmd --proxyurl https://127.0.0.1:8888 --proxyusername "user" --proxypassword "password"