Skip to content

Commit

Permalink
Merge pull request #655 from DFE-Digital/feature/health-checks
Browse files Browse the repository at this point in the history
Add DbContextChecks to Health Checks
  • Loading branch information
dneed-nimble authored Dec 5, 2024
2 parents 3af2765 + 641cb6e commit db53e87
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="8.0.11" />
<PackageReference Include="Microsoft.FeatureManagement.AspNetCore" Version="3.5.0" />
<PackageReference Include="Microsoft.Identity.Web" Version="2.21.1" />
<PackageReference Include="NetEscapades.AspNetCore.SecurityHeaders" Version="0.22.0" />
Expand Down
2 changes: 1 addition & 1 deletion DfE.FindInformationAcademiesTrusts/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public static void Main(string[] args)
ConfigurationVariables.BindConfigurationVariables(builder);

builder.Services.AddRazorPages();
builder.Services.AddHealthChecks();
builder.Services.AddApplicationInsightsTelemetry();
SecurityServicesSetup.AddSecurityServices(builder);

Expand All @@ -33,6 +32,7 @@ public static void Main(string[] args)
});

Dependencies.AddDependenciesTo(builder);
HealthCheckSetup.AddHealthChecks(builder);

var app = builder.Build();
PostBuildSetup.ConfigureApp(app);
Expand Down
20 changes: 20 additions & 0 deletions DfE.FindInformationAcademiesTrusts/Setup/HealthCheckSetup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.Diagnostics.CodeAnalysis;
using DfE.FindInformationAcademiesTrusts.Data.AcademiesDb.Contexts;
using DfE.FindInformationAcademiesTrusts.Data.FiatDb.Contexts;

namespace DfE.FindInformationAcademiesTrusts.Setup;

[ExcludeFromCodeCoverage]
public static class HealthCheckSetup
{
public static void AddHealthChecks(WebApplicationBuilder builder) {
builder.Services.AddHealthChecks();
AddDbHealthChecks(builder);
}

public static void AddDbHealthChecks(WebApplicationBuilder builder) {
builder.Services.AddHealthChecks()
.AddDbContextCheck<AcademiesDbContext>()
.AddDbContextCheck<FiatDbContext>();
}
}

0 comments on commit db53e87

Please sign in to comment.