如何使用 Azure 门户中的设置限制对应用服务的访问

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

我们有一个在 Azure 中作为应用服务部署的 Web 应用。我们想通过拥有一个 IP 地址白名单来限制对它的访问,这可以在某些 Azure 应用服务设置中完成,而不是在我们项目内部的 web.config 中完成。

目前,这就是我们在我们的环境中进行 IP 地址限制的方式。

这是HttpFailre_09-07-33.html

的部分内容
Module         IpRestrictionModule
Notification   BeginRequest
Handler        aspNetCore
Error Code     0x80070021
Config Error   This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false".

我们想从 web.config 中完全删除此 <security> 块,因为出于另一个原因,我们不希望 IP 地址达到生产。

而且,我们不允许在暂存服务器中进行 VNet 集成(管理方面的东西,呃!cost-cutting 无论如何!)。

那么有没有办法在 Azure 应用服务中限制 IP 地址?

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

1.We 可以使用 web.config 来限制您提到的 IP 地址

2.We 可以从 IIS 管理器连接到 WebApp,我们可以轻松配置限制 IP。更多详细信息请参考blog.

3.We 可以使用 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 。以下是有关如何使用 azure 资源管理器执行此操作的简单步骤。

一个。打开 azure resource explorer 和 select 相应的网站配置 web 选项点击 Edit 按钮。

b。将 ipSecurityRestrictions 更改为数组值。

c。单击 Put 按钮发送请求。

Config Error This configuration section cannot be used at this path

如果我们不解锁handlers,我们需要解锁handlers,更多信息请参考另一个。以下是从 SO 线程中截取的内容。

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 可以使用 powershell Az 模块命令在 Azure 应用服务上配置类型访问限制 - Add-AzWebAppAccessRestrictionRule

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