我需要为 Azure Functions 实施运行状况检查。
https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/health-checks?view=aspnetcore-3.0
但是,在我的情况下,我们需要在 NETCORE 2.2 中实现它而不是使用 NETCORE 3.0
我们的主要问题是从FunctionsStartup继承的启动类,它与 MVC API 启动有很大的不同。因此,以下代码无法在 Startup.cs 中实现
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
//Readiness check
var port = int.Parse(Configuration["HealthManagementPort"]);
app.UseHealthChecks("/ready", port, new HealthCheckOptions()
{
Predicate = (check) => check.Tags.Contains("ready"),
});
app.UseHealthChecks("/live", port, new HealthCheckOptions()
{
//Exclude all checks and return 200-OK
Predicate = (_) => false,
});
}
Run Code Online (Sandbox Code Playgroud)
有没有人遇到过类似的事情?我怎样才能实现类似的行为?
谢谢。