I have a script that removes and then adds firewall restrictions on Azure WebApp before doing a deployment. Below you will find the script
az webapp config access-restriction remove -g $(qa-rg) -n $(qa-app) --rule-name myip --action Allow --ip-address 157.71.103.203/32 --priority 1011
az webapp config access-restriction remove -g $(qa-rg) -n $(qa-app) --rule-name myip --action Allow --ip-address 157.71.173.703/32 --priority 1012
az webapp config access-restriction add -g $(qa-rg) -n $(qa-app) --rule-name myip --action Allow --ip-address 157.71.103.203/32 --priority 1011
az webapp config access-restriction add -g $(qa-rg) -n $(qa-app) --rule-name myip --action Allow --ip-address 157.71.173.703/32 --priority 1012
The issue with the above command is that, suppose someone has manually removed the firewall or the firewall does not exist for that user, then the script fails with an error in this case.
Is there a way to first check all the firewalls enabled for different users, then traverse and remove each of them and then finally again add all the firewall rules for the removed users.
Can someone please help me create this script as I am just learning scripting
Thanks