Class ApplicationDatabaseHealthCheck
- Namespace
- ProjectTemplate.Web.HealthChecks
- Assembly
- ProjectTemplate.Web.dll
Reports whether the application database accepts connections.
public sealed class ApplicationDatabaseHealthCheck : IHealthCheck
- Inheritance
-
ApplicationDatabaseHealthCheck
- Implements
- Inherited Members
Remarks
Registered with the Ready tag so an instance that cannot reach its database is removed from load balancing. The result description never includes connection strings or provider exception text. For SQLite, a database file that has not been created yet is reported as unavailable. When DatabaseReadinessCheckEnabled is false, the check reports healthy without contacting the database.
Constructors
ApplicationDatabaseHealthCheck(IServiceScopeFactory, IOptionsMonitor<ApplicationHealthCheckOptions>)
Reports whether the application database accepts connections.
public ApplicationDatabaseHealthCheck(IServiceScopeFactory scopeFactory, IOptionsMonitor<ApplicationHealthCheckOptions> options)
Parameters
scopeFactoryIServiceScopeFactoryoptionsIOptionsMonitor<ApplicationHealthCheckOptions>
Remarks
Registered with the Ready tag so an instance that cannot reach its database is removed from load balancing. The result description never includes connection strings or provider exception text. For SQLite, a database file that has not been created yet is reported as unavailable. When DatabaseReadinessCheckEnabled is false, the check reports healthy without contacting the database.
Methods
CheckHealthAsync(HealthCheckContext, CancellationToken)
Checks whether the application database accepts connections.
public Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
Parameters
contextHealthCheckContextThe health check context.
cancellationTokenCancellationTokenA token that cancels the check.
Returns
- Task<HealthCheckResult>
The database health result.