Skip to content

Commit

Permalink
#1929 Healthcheck config
Browse files Browse the repository at this point in the history
- Move common healthcheck configuration
  • Loading branch information
delager committed Apr 4, 2023
1 parent 0d350f9 commit 2805edd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,12 @@

namespace AzureIoTHub.Portal.Infrastructure.Startup
{
using AzureIoTHub.Portal.Infrastructure.ServicesHealthCheck;
using Microsoft.Extensions.DependencyInjection;

public static class AWSServiceCollectionExtension
{
public static IServiceCollection AddAWSInfrastructureLayer(this IServiceCollection services)
{
return services.ConfigureHealthCheck();
}
private static IServiceCollection ConfigureHealthCheck(this IServiceCollection services)
{
_ = services.AddHealthChecks()
.AddDbContextCheck<PortalDbContext>()
.AddCheck<DatabaseHealthCheck>("databaseHealthCheck");

return services;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,11 @@ private static IServiceCollection ConfigureServices(this IServiceCollection serv
private static IServiceCollection ConfigureHealthCheck(this IServiceCollection services)
{
_ = services.AddHealthChecks()
.AddDbContextCheck<PortalDbContext>()
.AddCheck<IoTHubHealthCheck>("iothubHealth")
.AddCheck<StorageAccountHealthCheck>("storageAccountHealth")
.AddCheck<TableStorageHealthCheck>("tableStorageHealth")
.AddCheck<ProvisioningServiceClientHealthCheck>("dpsHealth")
.AddCheck<LoRaManagementKeyFacadeHealthCheck>("loraManagementFacadeHealth")
.AddCheck<DatabaseHealthCheck>("databaseHealthCheck");
.AddCheck<LoRaManagementKeyFacadeHealthCheck>("loraManagementFacadeHealth");

return services;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace AzureIoTHub.Portal.Infrastructure.Startup
using AzureIoTHub.Portal.Domain;
using AzureIoTHub.Portal.Domain.Shared.Constants;
using AzureIoTHub.Portal.Infrastructure.Helpers;
using AzureIoTHub.Portal.Infrastructure.ServicesHealthCheck;
using EntityFramework.Exceptions.PostgreSQL;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
Expand All @@ -16,7 +17,8 @@ public static class IServiceCollectionExtension
public static IServiceCollection AddInfrastructureLayer(this IServiceCollection services, ConfigHandler configuration)
{
//Common configuration
services = services.ConfigureDatabase(configuration);
services = services.ConfigureDatabase(configuration)
.ConfigureHealthCheck();

//CloudProvider-dependant configurations
return configuration.CloudProvider switch
Expand Down Expand Up @@ -71,5 +73,14 @@ private static IServiceCollection ConfigureDatabase(this IServiceCollection serv

return services;
}

private static IServiceCollection ConfigureHealthCheck(this IServiceCollection services)
{
_ = services.AddHealthChecks()
.AddDbContextCheck<PortalDbContext>()
.AddCheck<DatabaseHealthCheck>("databaseHealthCheck");

return services;
}
}
}
2 changes: 1 addition & 1 deletion src/AzureIoTHub.Portal.Server/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void ConfigureServices(IServiceCollection services)
case CloudProviders.AWS:
ConfigureServicesAWS(services, configuration);
break;
//
// Code line not reachable
default:
break;
}
Expand Down

0 comments on commit 2805edd

Please sign in to comment.