如何解决警告:“应用程序由于重定向而被评估为不健康".在Azure运行状况检查功能上 [英] How to fix warning: "Application evaluated unhealthy due to redirection." on Azure Health Check Feature
问题描述
我运行了诊断并解决问题"在其中一个应用程序服务中的Azure仪表板上,然后我收到此严重风险警报:由于重定向,应用程序评估为不健康."
建议的操作是:
如果应用程序具有HTTP到HTTPS redirectoin,请考虑以下解决方案之一.一种.从TLS/SSL设置刀片中为相应的App Service启用仅HTTPs".这将强制运行状况检查ping超过443.b.修改应用程序逻辑/URL重写规则,以便来自用户代理的请求– ReadyForRequest/1.0 +(HealthCheck)&HealthCheck/1.0不会重定向.
我已经按照(a)点的建议启用了仅HTTPs",但我不知道如何执行(b)点.如何修改应用程序逻辑/广告和URL重写规则,以便来自用户代理的请求– ReadyForRequest/1.0 +(HealthCheck)
& HealthCheck/1.0
是否未重定向?
当前,我启用运行状况检查并将运行状况检查"路径设置为/
.
谢谢您的帮助.
我下载了官方示例,并对代码进行了一些更改,希望对您有用.
示例代码---
我将在您的另一篇文章中添加方法2
.
I ran "Diagnose and solve problems" on Azure dashboard inside one of the app services, and then I got this critical risk alert: "Application evaluated unhealthy due to redirection.".
Recommended actions is:
If the application has HTTP to HTTPS redirectoin, consider one of the following solutions.
a. Enable 'HTTPs Only' from the TLS/SSL settings blade for the respective App Service. This will force health check pings to over 443.
b. Modify the Application logic/ad a URL Rewrite rule so that requests from the user agents – ReadyForRequest/1.0+(HealthCheck) & HealthCheck/1.0 are not redirected.
I already enable 'HTTPs Only' as suggested on point (a), but I don't know how to do point (b). How to modify the Application logic/ad a URL Rewrite rule so that requests from the user agents – ReadyForRequest/1.0+(HealthCheck)
& HealthCheck/1.0
are not redirected ?
Currently, I enable Health Check and set the Health Check path to /
.
Thanks before for any help.
I download offical sample, and make some changes in code, hope it useful to you.
Sample Code --- .net core 3.X(HealthChecksSample)
Method 1.
Because the code is in .net core, I first recommend configuring rewrite in Startup.cs
.
public void Configure(IApplicationBuilder app)
{
app.UseHealthChecks("/");
app.UseRouting();
app.MapWhen(
ctx => ctx.Request.Path.StartsWithSegments("/"),
appBuilder =>
{
appBuilder.UseMiddleware<HealthCheckMiddleware>();
}
);
app.UseEndpoints(endpoints =>
{
endpoints.MapHealthChecks("/");
endpoints.MapGet("/{**path}", async context =>
{
await context.Response.WriteAsync(
"Navigate to /health to see the health status.");
});
});
}
It works for me, both in local and azure web app.
I will add Method 2
in your another post.
这篇关于如何解决警告:“应用程序由于重定向而被评估为不健康".在Azure运行状况检查功能上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!