How to restrict access to an App Service using a setting inside the Azure Portal How to restrict access to an App Service using a setting inside the Azure Portal azure azure

How to restrict access to an App Service using a setting inside the Azure Portal


So is there a way to restrict IP addresses in Azure App Service?

1.We could use web.config to restrict IP address as you mentioned

2.We could connect to a WebApp from IIS manager and we can config restrict IP easily. More detail info please refer blog.

3.We could use REST API to do that, and we could easily do it with Azure Resource Exploer(https://resources.azure.com/). We also could do that with PowerShell cmdlets detail info please refer to another SO Thread. The following is the simple steps about how to use azure resource explorer to do that.

a. Open azure resource explorer and select the corresponding web site config web option to click the Edit button.

enter image description here

b. Change ipSecurityRestrictions to an array value.

enter image description hereenter image description here

c. Click the Put button to send request.

enter image description here

Config Error This configuration section cannot be used at this path

If we do not unlock the handlers, we need to unlock the handlers, more info please refer to another SO Thread. Following is the snipped from the SO thread.

1) In the connections tree(in IIS), go to your server node and then to your website.

2) For the website, in the right window you will see configuration editor under Management.

3) Double click on the configuration editor.

4) In the window that opens, on top you will find a drop down for sections. Choose "system.webServer/handlers" from the drop down.

5) On the right side, there is another drop down. >Choose "ApplicationHost.Config "

6) On the right most pane, you will find "Unlock Section" under "Section" heading. Click on that.

7) Once the handlers at the applicationHost is unlocked, your website should run fine.


VNet/subnet type Access Restrictions can be configured on Azure App Service using powershell Az module command - Add-AzWebAppAccessRestrictionRule

https://docs.microsoft.com/en-us/powershell/module/az.websites/add-azwebappaccessrestrictionrule?view=azps-3.2.0