Skip to content
This repository was archived by the owner on Apr 17, 2025. It is now read-only.

Commit cef08b8

Browse files
committed
Resolve issue #31
closes #31
1 parent 553ec86 commit cef08b8

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Health Checks configuration for SQL server database
2+
3+
4+
## Configuration to add to the appsettings.json file
5+
6+
```json
7+
"ConnectionStrings": {
8+
"Default": "Data Source=[SERVER];Initial Catalog=[DATABASE];User ID=[USERNAME];Password=[PASSWORD]"
9+
//or "Default": "Data Source=[SERVER];Initial Catalog=[DATABASE];User ID=[USERNAME];Password=[PASSWORD];Encrypt=False"
10+
},
11+
```
12+
13+
14+
## Registering services at Startup
15+
16+
```csharp
17+
public Startup(IConfiguration configuration)
18+
{
19+
Configuration = configuration;
20+
}
21+
22+
public IConfiguration Configuration { get; }
23+
24+
public void ConfigureServices(IServiceCollection services)
25+
{
26+
var connectionString = Configuration.GetSection("ConnectionStrings").GetValue<string>("Default");
27+
services.AddSqlServerHealthChecks(connectionString, "SQLServer");
28+
}
29+
30+
//OMISSIS
31+
32+
public void Configure(WebApplication app)
33+
{
34+
//OMISSIS
35+
36+
app.UseEndpoints(endpoints =>
37+
{
38+
endpoints.MapControllers();
39+
endpoints.AddDatabaseHealthChecks("/status", false); //Use the True parameter if access is to be in AllowAnonymous mode
40+
}
41+
}
42+
```

0 commit comments

Comments
 (0)