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
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.
In case you came looking here becasue you're getting this error when trying to use Azure DevOps to MSBuild and deploy to an Azure SQL server and going slightly mad because nothing seems to be on the internet and people are all taking about using power shell scripts to find out the IP address of the server and white listing etc.., then you may be better of using a task called "Azure SQL Database deployment" in your yml file as well as the MSBuild like so:
- task: MSBuild@1
displayName: Build the database project
inputs:
solution: '**/projectname.sqlproj'
msbuildArguments: '/t:Restore /t:Build '
- task: SqlAzureDacpacDeployment@1
inputs:
azureSubscription: ''
AuthenticationType: 'server'
ServerName: '.database.windows.net'
DatabaseName: ''
SqlUsername: ''
SqlPassword: ''
deployType: 'DacpacTask'
DeploymentAction: 'Publish'
DacpacFile: '**/projectname.dacpac'
IpDetectionMethod: 'AutoDetect'
the IpDetectionMethod of auto worked for me put it does allow you to easily put in your own values (although i haven't tried that)
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.
We need to white list the IP address used by the Azure Datacenters in the list mentioned below: https://www.microsoft.com/en-nz/download/details.aspx?id=41653
Note: This list gets updated every week, so please be mindful of this during the deployment planning