使用门户创建应用程序网关的自定义探测Create a custom probe for Application Gateway by using the portal

本文介绍如何通过 Azure 门户向现有应用程序网关添加自定义探测。In this article, you add a custom probe to an existing application gateway through the Azure portal. 如果应用程序包含特定运行状况检查页面。或者未在默认 Web 应用程序上提供成功的响应,那么它们非常适合使用自定义探测。Custom probes are useful for applications that have a specific health check page or for applications that do not provide a successful response on the default web application.

准备阶段Before you begin

如果还没有应用程序网关,请访问创建应用程序网关,创建要使用的应用程序网关。If you do not already have an application gateway, visit Create an Application Gateway to create an application gateway to work with.

创建探测Create the probe

可通过门户分两步配置探测。Probes are configured in a two-step process through the portal. 第一步是创建探测。The first step is to create the probe. 第二步是将探测添加到应用程序网关的后端 http 设置。In the second step, you add the probe to the backend http settings of the application gateway.

  1. 登录到 Azure 门户Log in to the Azure portal. 如果还没有帐户,可以注册 1 元试用版If you don't already have an account, you can sign up for a 1rmb-trial

  2. 在 Azure 门户的“收藏夹”窗格中单击“所有资源”。In the Azure portal Favorites pane, click All resources. 在“所有资源”边栏选项卡中单击应用程序网关。Click the application gateway in the All resources blade. 如果所选订阅中已包含多个资源,则可在“按名称筛选…”框中输入“partners.contoso.net”,If the subscription you selected already has several resources in it, you can enter partners.contoso.net in the Filter by name… 轻松访问应用程序网关。box to easily access the application gateway.

  3. 单击“探测” ,然后单击“添加” 按钮添加探测。Click Probes and click the Add button to add a probe.

    添加填写了信息的“探测”边栏选项卡

  4. 在“添加运行状况探测” 边栏选项卡上填写探测的必填信息,并在完成时单击“确定” 。On the Add health probe blade, fill out the required information for the probe, and when complete click OK.

    设置Setting Value 详细信息Details
    名称Name customProbecustomProbe 此值是可在门户中访问的探测的友好名称。This value is a friendly name to the probe that is accessible in the portal.
    协议Protocol HTTP 或 HTTPSHTTP or HTTPS 运行状况探测使用的协议。The protocol that the health probe uses.
    主机Host 例如i.e contoso.comcontoso.com 此值是用于探测的主机名。This value is the host name that is used for the probe. 仅在应用程序网关上配置了多站点的情况下适用,否则使用“127.0.0.1”。Applicable only when multi-site is configured on Application Gateway, otherwise use '127.0.0.1'. 此值与 VM 主机名不同。This value is different from the VM host name.
    路径Path / 或另一个路径/ or another path 自定义探测的完整 URL 的其余部分。The remainder of the full url for the custom probe. 有效路径以“/”开头。A valid path starts with '/'. 对于默认路径 http://contoso.com,只需使用“/”For the default path of http://contoso.com just use '/'
    间隔(秒)Interval (secs) 3030 运行探测来检查运行状况的频率。How often the probe is run to check for health. 建议不要将时间间隔设置为短于 30 秒。It is not recommended to set the lower than 30 seconds.
    超时(秒)Timeout (secs) 3030 超时之前探测的等待时间。超时间隔必须足够长,以便进行 http 调用,确保后端运行状况页可用。The amount of time the probe waits before timing out. The timeout interval needs to be high enough that an http call can be made to ensure the backend health page is available.
    不正常阈值Unhealthy threshold 33 系统认为不正常的失败尝试次数。Number of failed attempts to be considered unhealthy. 阈值可以设置为 1 或更大值。The threshold can be set to 1 or more.

    Important

    主机名不同于服务器名。The host name is not the same as server name. 此值是运行在应用程序服务器上的虚拟主机的名称。This value is the name of the virtual host running on the application server. 探测发送到 http://(主机名):(httpsetting 中的端口)/urlPathThe probe is sent to http://(host name):(port from httpsetting)/urlPath

向网关添加探测Add probe to the gateway

创建探测以后,即可将其添加到网关。Now that the probe has been created, it is time to add it to the gateway. 探测设置在应用程序网关的后端 http 设置中设置。Probe settings are set on the backend http settings of the application gateway.

  1. 单机应用程序网关的“HTTP 设置” ,然后单击窗口中列出的当前后端 http 设置,以便显示“配置”边栏选项卡。Click HTTP settings on the application gateway, to bring up the configuration blade click the current backend http settings listed in the window.

    https 设置窗口

  2. 在“appGatewayBackEndHttpSettings” 设置边栏选项卡上,选中“使用自定义探测” 复选框,然后在“自定义探测” 下拉列表中选择在创建探测部分创建的探测。On the appGatewayBackEndHttpSettings settings blade, check the Use custom probe checkbox and choose the probe created in the Create the probe section on the Custom probe drop-down.. 完成后,单击“保存” 即可应用相关设置。When complete, click Save and the settings are applied.

默认探测检查对 Web 应用程序的默认访问权限。The default probe checks the default access to the web application. 现已创建自定义探测,因此应用程序网关可以使用定义的自定义路径来监视后端服务器的运行状况。Now that a custom probe has been created, the application gateway uses the custom path defined to monitor health for the backend servers. 应用程序网关根据所定义的条件检查探测中指定的路径。Based on the criteria that was defined, the application gateway checks the path specified in the probe. 如果调用 host:Port/path 时没有返回 HTTP 200-399 状态响应,则在达到不正常阈值后,服务器不再进行轮换。If the call to host:Port/path does not return an HTTP 200-399 status response, the server is taken out of rotation after the unhealthy threshold is reached. 将继续对不正常的实例进行探测,确定其何时恢复正常。Probing continues on the unhealthy instance to determine when it becomes healthy again. 将实例添加回正常的服务器池以后,其流量即可恢复,同时也会继续按用户指定的正常时间间隔对实例进行探测。Once the instance is added back to healthy server pool, traffic begins flowing to it again and probing to the instance continues at user specified interval as normal.

后续步骤Next steps

若要了解如何通过 Azure 应用程序网关来配置 SSL 卸载,请参阅配置 SSL 卸载To learn how to configure SSL Offloading with Azure Application Gateway, see Configure SSL Offload