【问题标题】:IApplicationBuilder does not includes a definition for UseHealthChecksIApplicationBuilder 不包括 UseHealthChecks 的定义
【发布时间】:2019-02-08 22:00:18
【问题描述】:

正如kubernetes health check 教程中所建议的那样,我喜欢在我的 .NET Core WebApi 的类 startup.cs 的方法 Configure 中实现运行状况检查。 但.UseHealthCheck() 方法未知。 我不知道是什么造成了这个问题。我想所有用途都在那里?!?

        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        app.UseHealthChecks("/health");
        app.Run(async (context) =>
        {
            await context.Response.WriteAsync(
                "Navigate to /health to see the health status.");
        });

这里是使用:

    using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Authorization;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Identity.Client;
using Microsoft.IdentityModel.Logging;
using Microsoft.IdentityModel.Protocols;
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
using Microsoft.IdentityModel.Tokens;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IdentityModel.Tokens.Jwt;
using System.Linq;

如何解决这个问题?

感谢您的帮助! 弗兰克

【问题讨论】:

标签: kubernetes-health-check


【解决方案1】:

感谢 mxmissile! 我添加了 NuGet 包

Microsoft.AspNetCore.Diagnostics.HealthChecks 2.2.0

and there for also and first

Microsoft.AspNetCore.Http.Features 2.2.0
Microsoft.AspNetCore.Http.Abstractions 2.2.0
Microsoft.Net.Http.headers 2.2.0

现在方法已经知道了。

【讨论】:

  • 我还需要安装 Microsoft.Extensions.Diagnostics.HealthChecks 包。
猜你喜欢
  • 2021-12-05
  • 2019-09-22
  • 2018-07-22
  • 2017-07-31
  • 1970-01-01
  • 2018-01-27
  • 2017-02-13
  • 2022-01-22
  • 2012-01-04
相关资源
最近更新 更多