Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the IP Address for Azure DevOps Hosted Agents to add to the white list

Is there a way to the IP address range for the hosted machine running?

This is related to the Release Pipeline -> Hosted agent.

Issue: Getting access denied on connection, as the connection is getting refused via Firewall. Need to whitelist the IP address range for this request coming from release pipeline on DevOps.

like image 522
Gagan Jeet Singh Avatar asked Nov 22 '18 00:11

Gagan Jeet Singh


People also ask

How do I get Azure DevOps agent IP?

Thankfully, the Microsoft-hosted Build Agents have Internet access, and you can use a service such as http://ipinfo.io/ip to retrieve the Public IP Address of the Build Agent.

Does Azure DevOps have an IP address?

Azure DevOps import service During the import process, we highly recommend that you restrict access to your virtual machine (VM) to only IP addresses from Azure DevOps. To restrict access, allow only connections from the set of Azure DevOps IP addresses, which were involved in the collection database import process.


2 Answers

I have a step in a release that gets the Hosted Agent IP address in powershell with:

Invoke-RestMethod http://ipinfo.io/json | Select -exp ip
Hope that helps.
like image 100
David Niwczyk Avatar answered Sep 18 '22 19:09

David Niwczyk


Use a script step in the pipeline to get the current external ip and whitelist it. after pipeline finishes use another script step to clean up.

Thats the only way (for hosted agent), unfortunately.

like image 21
4c74356b41 Avatar answered Sep 18 '22 19:09

4c74356b41