在没有 public URL 的情况下配置 Azure 应用服务

Configure Azure App Service without public URL

我正在尝试从 Visual Studio 15.2 部署 Azure 应用服务。具体来说,我正在尝试部署以下服务:https://github.com/Microsoft/Azure-SQL-DB-auditing-OMS-integration 以将审计日志从 SQL 数据仓库提取到 OMS。但是,出于安全考虑,我们希望在不创建 public 端点的情况下这样做,即 url。我们已尝试在 VNet 中配置它,但它不允许您这样做,除非 VNet 具有 public 网关。

Configure Azure App Service without public URL

据我所知,如果没有 public URL,我们无法配置 Azure 应用服务。如果您创建了网络应用程序,它将自动提供 public 端点供用户访问。

这里有两个解决方法。

我发现 github 应用程序只使用网络应用程序的 webjobs。

一种方式:

如果您不需要任何网站,只需使用 backgourd 进程 运行 webjobs,您可以选择 azure function which uses WebJobs SDK 本身,但不需要为其配置应用服务它。

第二种方式:

通常我们 运行 Azure App Service Web 应用程序中的 WebJobs,并且该 Azure App Service Web 应用程序可以 accessed/browsed 通过 URL。如果要阻止用户浏览到该 Azure App Service Web 应用程序,可以将站点的 web.config 添加到 block web access.

的重写规则

web.config是这样的:

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  https://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Block unauthorized traffic to staging sites" stopProcessing="true">
          <match url=".*" />
          <conditions>
            <!-- Enter your staging site host name here as the pattern-->
            <add input="{HTTP_HOST}" pattern=".*" />
            <!-- Enter your white listed IP addresses -->
            <add input="{REMOTE_ADDR}" pattern="123\.123\.123\.1" negate="true"/>
            <!-- Add the white listed IP addresses with a new condition as seen below -->
            <!-- <add input="{REMOTE_ADDR}" pattern="123\.123\.123\.2" negate="true"/> -->

          </conditions>
          <action type="CustomResponse" statusCode="403" statusReason="Forbidden"
        statusDescription="Site is not accessible" />

        </rule>

      </rules>
    </rewrite>
  </system.webServer>

</configuration>

有关如何将 web.config 添加到您的网络应用程序的更多详细信息,您可以按照以下步骤操作:

1.Open Web 门户中的 kudu 工具。

2.Open cmd 控制台并找到 \site\wwwroot 文件夹。

3.Create web.config 复制里面的设置。

4.When 我们访问了这个网站,你可以找到这个: