我找不到任何资源来将运行状况检查添加到在 .NET 5.0 隔离中运行的 HTTPTrigger 函数应用程序。
static async Task Main()
{
var host = new HostBuilder()
.ConfigureAppConfiguration(configurationBuilder =>
{
configurationBuilder.AddEnvironmentVariables();
})
.ConfigureFunctionsWorkerDefaults()
.ConfigureServices((builder, services) =>
{
var configuration = builder.Configuration;
services.AddDbContext(configuration);
// Add healthcheck here
services.AddHealthChecks()
// ...
// Map health checks
})
.Build();
await host.RunAsync();
}
本指南指出我可以添加 MapHealthChecks(但在 asp.net 核心中)
var app = builder.Build();
app.MapHealthChecks("/healthz");
app.Run();
如何将其翻译为在我的 dotnet 隔离应用程序中运行?