IApplicationBuilder不包含UseHealthChecks的定义

时间:2019-02-08 22:00:18

标签: kubernetes-health-check

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

        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;

如何解决此问题?

感谢您的帮助! 弗兰克

1 个答案:

答案 0 :(得分:2)

感谢mxmissile! 我添加了NuGet包

Microsoft.AspNetCore.Diagnostics.HealthChecks 2.2.0

在那也要先

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

现在该方法是已知的。