Added LDAP health checks

This commit is contained in:
2025-10-03 17:24:51 +02:00
parent 342cfbf1ca
commit 999748913b
2 changed files with 37 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ using Serilog;
using Microsoft.AspNetCore.Authentication.Cookies;
using Berufsschule_HAM.Services;
using Berufsschule_HAM.Models;
using Berufsschule_HAM.HealthChecks;
var builder = WebApplication.CreateBuilder(args);
// Bind options
@@ -26,6 +27,9 @@ builder.Services.AddElmah<XmlFileErrorLog>(Options =>
builder.Services.AddSingleton<LdapService>();
builder.Services.AddSingleton<MigrationService>();
builder.Services.AddHealthChecks()
.AddCheck<DatabaseHealthCheck>("DatabaseHealthCheck");
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(options =>
{
@@ -53,6 +57,8 @@ app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
app.MapHealthChecks("/healthz");
// Run migrations
using var scope = app.Services.CreateScope();
var migrationService = scope.ServiceProvider.GetRequiredService<MigrationService>();