【问题标题】:Configure Azure App Service without public URL配置没有公共 URL 的 Azure 应用服务
【发布时间】:2017-08-14 00:16:46
【问题描述】:

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

【问题讨论】:

    标签: azure endpoint azure-web-app-service vnet sql-data-warehouse


    【解决方案1】:

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

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

    这里有两个解决方法。

    我发现 github 应用程序只是使用 web 应用程序的 webjobs。

    一种方式:

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

    第二种方式:

    通常我们在 Azure App Service Web 应用程序中运行 WebJobs,并且可以通过 URL 访问/浏览该 Azure App Service Web 应用程序。如果要阻止用户浏览到该 Azure 应用服务 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.在门户中打开kudu工具。

    2.打开cmd控制台,找到\site\wwwroot文件夹。

    3.创建 web.config 并复制其中的设置。

    4.当我们访问该网站时,您会发现:

    【讨论】:

    • 好的,我得到了使用 web.config 的第二个解决方案。非常感谢您的解决方案!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-10-31
    • 1970-01-01
    • 2020-07-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-08
    相关资源
    最近更新 更多