IApplicationBuilder does not includes a definition for UseHealthChecks

2/8/2019

As suggested at the tutorial for kubernetes health check I like to implement the health chack at my .NET Core WebApi at class startup.cs at method Configure. But the method .UseHealthCheck() is unknown. I don't know what creates this problem. I guess all usings are there?!? 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.");
        });

here the using:

    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;

How to fix this problem?

Thanks for your help! Frank

-- Frank Mehlhop
kubernetes-health-check

1 Answer

2/8/2019

Thanks mxmissile! I add the NuGet package

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

Now the method is known.

-- Frank Mehlhop
Source: StackOverflow