diff --git a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.API/Dfe.ManageFreeSchoolProjects.API.csproj b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.API/Dfe.ManageFreeSchoolProjects.API.csproj
index 66226fea5..86b9dfac3 100644
--- a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.API/Dfe.ManageFreeSchoolProjects.API.csproj
+++ b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.API/Dfe.ManageFreeSchoolProjects.API.csproj
@@ -39,6 +39,7 @@
+
diff --git a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.API/Startup.cs b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.API/Startup.cs
index fd4ba2ea2..02b632617 100644
--- a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.API/Startup.cs
+++ b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.API/Startup.cs
@@ -81,6 +81,8 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IApiVers
app.UseAuthorization();
app.UseManageFreeSchoolProjectsEndpoints();
+
+ app.UseHealthChecks("/health");
}
}
}
diff --git a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.API/StartupConfiguration/DatabaseConfigurationExtensions.cs b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.API/StartupConfiguration/DatabaseConfigurationExtensions.cs
index 2fe7f5b36..39d9b80a4 100644
--- a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.API/StartupConfiguration/DatabaseConfigurationExtensions.cs
+++ b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.API/StartupConfiguration/DatabaseConfigurationExtensions.cs
@@ -13,6 +13,13 @@ public static IServiceCollection AddDatabase(this IServiceCollection services, I
services.AddScoped();
+ AddDbHealthCheck(services);
+
return services;
}
-}
\ No newline at end of file
+
+ public static void AddDbHealthCheck(IServiceCollection services) {
+ services.AddHealthChecks()
+ .AddDbContextCheck("Manage Free School Projects Database");
+ }
+}
diff --git a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/Startup.cs b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/Startup.cs
index f07971c56..862a433ec 100644
--- a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/Startup.cs
+++ b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/Startup.cs
@@ -64,7 +64,6 @@ public void ConfigureServices(IServiceCollection services)
{
services.AddHttpClient();
services.AddFeatureManagement();
- services.AddHealthChecks();
services
.AddRazorPages(options =>
{
@@ -72,7 +71,7 @@ public void ConfigureServices(IServiceCollection services)
options.Conventions.AllowAnonymousToPage("/Public/AccessibilityStatement");
options.Conventions.AllowAnonymousToPage("/Public/Cookies");
options.Conventions.AllowAnonymousToPage("/Account/AccessDenied");
- })
+ })
.AddViewOptions(options =>
{
options.HtmlHelperOptions.ClientValidationEnabled = false;
@@ -118,7 +117,7 @@ public void ConfigureServices(IServiceCollection services)
services.AddScoped();
services.AddScoped();
services.AddScoped();
- services.AddScoped();
+ services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
@@ -181,6 +180,8 @@ public void ConfigureServices(IServiceCollection services)
});
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
+
+ SetupHealthChecks(services);
}
private void SetupDataprotection(IServiceCollection services)
@@ -202,6 +203,11 @@ private void SetupDataprotection(IServiceCollection services)
}
}
+ private static void SetupHealthChecks(IServiceCollection services)
+ {
+ services.AddHealthChecks();
+ }
+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogger logger)
{
// Ensure we do not lose X-Forwarded-* Headers when behind a Proxy