Azure - 高级应用程序重启 - 在实例准备就绪之前访问实例

Azure - Advanced Application restart - access to instance before it's ready

我有一个在 2 个实例上 运行 的 Azure 应用程序服务。我尝试了高级应用程序重启并设置了 90 秒或更长时间的重启延迟。

当其中一个实例重新启动时,客户端请求似乎仍会发送到正在重新启动的实例。我看到 return.

请求花费了 60 多秒

我原以为当其中一个实例重新启动时,它在准备好处理请求之前是不可用的。

如果我需要重新启动其中一个实例,我如何确保不会对任何人造成干扰?

ASP.Net 4.6.1

Use the AppInit feature :

With the AppInit feature, a new web app instances are added into the rotation, we ensure that the Application Initialization module reports that the site is fully warmed up before sending it a request from the frontend. To use the feature, add an applicationInitialization section to your web.config like so:
 
<system.webServer>        
  <applicationInitialization remapManagedRequestsTo="/Content/warmup.html"> 
     <add initializationPage="/api/values/100" /> 
  </applicationInitialization>
</system.webServer>
 
You can have multiple initialization pages, and the AppInit module will ensure that all of them return 200 before declaring the site officially warmed up. Meanwhile, you can (optionally) use the remapManagedRequestsTo attribute to have a friendly page showing that the site is still warming up.  Thanks to the AppInit feature, this page will not be visible to customers while adding new instances into rotation, however if a process crashes for whatever reason and enters AppInit again, it will come into play.

Azure Web 应用程序默认安装应用程序初始化模块。您可以直接从 web.config 文件或通过 apphost.config XDT 配置它。只需将上面的内容粘贴到网络应用程序根目录中的 web.config 即可。

您也可以点击以下链接了解更多信息。 https://docs.microsoft.com/en-us/iis/configuration/system.webserver/applicationinitialization/#configuration

https://ruslany.net/2015/09/how-to-warm-up-azure-web-app-during-deployment-slots-swap/

HTTP 和 HTTPS 探测建立在 TCP 探测之上,并使用指定路径发出 HTTP GET。探测器与 HTTP 探测器相同,只是增加了传输层安全性(TLS,以前称为 SSL)包装器。默认情况下,health probe 每 15 秒尝试检查配置的健康探测端口。您可以将探测时间减少到 5 秒,如下所示:

{
    "name": "http",
    "properties": {
    "protocol": "Http",
    "port": 80,
    "requestPath": "/",
    "intervalInSeconds": 5,
    "numberOfProbes": 2
}

如果你有 Application Gateway 你也可以配置它。

注意:Azure 网站内部会查看整个服务器的健康状况,如果服务器不健康,它将不会接收请求。更详细的可以参考这个.