Whitelist Hosted Agent IP address in AzureDevOps pipeline (For Sitecore Unicorn Sync)
Updated on 22 May 2020
Updated the script in Github from the old AzureRM PowerShell to work with new Az PowerShell.
I have also tried upgrading the script to Azure CLI, but it takes more than 1 minute to run Azure CLI version comparing to 30 seconds for Az PowerShell, so didn’t do it.
Setting up CICD for a Sitecore 9 PaaS set up with Azure App Services on Azure DevOps recently and during the final stage, while trying to set up Unicorn sync task, it fails due to the IP restriction on the web app that’s set up to hide the non-production environment from the internet.
Found an extension in the Marketplace that can add build agent IP however it doesn’t remove: Link to Extension
Since it is a PowerShell script, grabbed the code and made some changes so now it can be used to add and remove build agent IP addresses.
The PowerShell script is here: Link to Github
In Azure DevOps, use “Azure PowerShell” task. You can use inline or save the script into a file. It has the following parameters to set:
- ResGrpName = Azure Resource Group Name
- AppName = Azure Web App Name
- SlotName = Azure Web App Slot Name
- IsAdd = $true for adding build agent IP, $false for removing the IP
The plan is to convert it into an extension, so it’s easier to use (Will check on licensing). But for now, it does its job. Keep an eye here for more updates.