azure AzureDevOps powershell stepUpChallenge

Add/Update IP Restrictions on Azure WebApp Dynamically with PowerShell

Well, it’s exactly a month since my last post on estimation of parallel jobs on AzureDevOps. I was away all this while due to a shoulder injury. I got both my shoulders dislocated and was hospitalized due to that for quite some while. I finally got to working full time last week only and here I’m back today with a small yet powerful trick to add or update IP restrictions on an Azure WebApp dynamically through Powershell.

Let’s step up the context first. I was working in Azure DevOps Pipelines and had a requirement to add and allow the IP of my hosted agent in the IP Restrictions of Azure WebApp. I searched through the Azure Powershell cmdlets but failed to find any cmdlet that would do this job in a single command. It was then time to implement a script and get the job done. I referred to a few scripts online available by different authors and came up with a script that would add and update the IP of my hosted agent in the Azure WebApp each time upon run.


This script will first get the public IP Address of the host machine. Then, that IP will get added to the custom rule that is to be set on the Azure WebApp. The priority and the action to allow or deny rule can be set in this rule block.

We, then get the Azure WebApp’s configuration and add/update the IP restrictions of the WebApp by setting the updated configuration.

Access Restrictions – Azure WebApp


Akhil Sharma

Akhil Sharma
DevOps Engineer, Horizontal Digital India
Azure Content Hero
Microsoft Certified: Azure DevOps Engineer Expert
Microsoft Certified: Azure Administrator Associate
Google Cloud Certified: Associate Cloud Engineer
Oracle Cloud Infrastructure Architect Associate
Oracle Cloud Infrastructure Foundations Associate
Oracle Cloud Infrastructure Cloud Operations Associate
Oracle Cloud Infrastructure Developer Associate
Oracle Autonomous Database Cloud Specialist
Aviatrix Certified Engineer - Multi-Cloud Network Associate
Lean Six Sigma White Belt Certified - v4.0
5+ Years of experience in DevOps
For more info, please read "About Me!"

Please subscribe for updates using the bell icon on your screen!
Back To Top
error: Content is protected !!
%d bloggers like this: