How to get the IP Address for Azure DevOps Hosted Agents to add to the white list
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.
Check out this add on for Azure DevOps (https://marketplace.visualstudio.com/items?itemName=MartijnQuekel.AzureAppServiceIPRestrictions). It allows you to alter your App Service IP restrictions during the build pipeline.
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.