From 80f30a2820abeb8fb0b6bdbeffd5323542cfe38a Mon Sep 17 00:00:00 2001 From: "Stein A. Hoem" Date: Mon, 25 Mar 2024 20:32:14 +0100 Subject: [PATCH] Add basic healthchecks --- Nbic.References/Nbic.References.csproj | 4 +++- Nbic.References/Startup.cs | 12 ++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Nbic.References/Nbic.References.csproj b/Nbic.References/Nbic.References.csproj index 87ec15c..e352935 100644 --- a/Nbic.References/Nbic.References.csproj +++ b/Nbic.References/Nbic.References.csproj @@ -9,7 +9,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -18,6 +18,8 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive + + diff --git a/Nbic.References/Startup.cs b/Nbic.References/Startup.cs index edb88c7..cb7b38e 100644 --- a/Nbic.References/Startup.cs +++ b/Nbic.References/Startup.cs @@ -1,7 +1,6 @@ // ReSharper disable once StyleCop.SA1634 // ReSharper disable StyleCop.SA1600 -using Microsoft.ApplicationInsights; using Nbic.References.Infrastructure.Repositories; using Nbic.References.Infrastructure.Repositories.DbContext; using Nbic.References.Infrastructure.Services.Indexing; @@ -92,7 +91,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogger< app.UseAuthentication(); app.UseAuthorization(); - + app.UseHealthChecks("/hc"); app.UseEndpoints(endpoints => { endpoints.MapControllers(); @@ -137,7 +136,12 @@ public void ConfigureServices(IServiceCollection services) .WithExposedHeaders("WWW-Authenticate"); }); }); - + + // health monitoring + services.AddHealthChecks() + .AddDbContextCheck(); + + // no search engine indexing services.AddStaticRobotsTxt(builder => builder.DenyAll()); } @@ -330,7 +334,7 @@ private void AddSwaggerMiddleware(IApplicationBuilder app) // c.OAuthAdditionalQueryStringParams(new { foo = "bar" }); c.OAuthUseBasicAuthenticationWithAccessCodeGrant(); c.RoutePrefix = string.Empty; - c.DocumentTitle = "Nbic Reference API - swagger documentation"; + c.DocumentTitle = "Nbic Reference API - swagger documentation"; // Since swagger doc i index.html - modify title }); } } \ No newline at end of file