Search code examples
azure-resource-managerazure-rm-templateazure-webapps

Is there a way to specify both IPaddress and Subnet Id to webapp's access restrictions using ARM templates


I have a list of IP addresses and a specific subnet which are to be allowed access to webapp. I'm able to loop through the IP restrictions using copy function in ARM templates but I'm unable to add the subnet restriction in the same template. Is there a way I can get through this?


Solution

  • After going through a lot of docs and blogs, I found no way to achieve it using the same ARM template. In my case, I want to add both IP addresses and a subnet while using a copy function(rather call it an ARM foreach loop). So, for adding multiple IP addresses(which are dynamically fetched within the ARM template from an other resource) and a subnet, I've got it resolved by executing the ARM first(this iterates and adds dynamically fetched IPs) and then a simple Az cmd as below which would add a security restriction to the same web app.

    Add-AzWebAppAccessRestrictionRule -ResourceGroupName $ResourceGroupName -WebAppName $WebAppName -Name "subnet rule" -Priority 301 -Action Allow -SubnetName $subnetName -VirtualNetworkName $VnetName

    That way both are in place :D