This repository was archived by the owner on Apr 17, 2025. It is now read-only.
File tree 2 files changed +86
-0
lines changed
src/NET6CustomLibrary/Docs/HealthChecks
2 files changed +86
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Health Checks configuration for MySQL database
2
+
3
+
4
+ ## Configuration to add to the appsettings.json file
5
+
6
+ ``` json
7
+ "ConnectionStrings" : {
8
+ "Default" : " Server=[SERVER];Database=[DATABASE];Uid=[USERNAME];Pwd=[PASSWORD];Port=3306"
9
+ },
10
+ ```
11
+
12
+ <b >Note:</b > The default port for Mysql / MariaDB is 3306, but it can be changed as needed according to your needs.
13
+
14
+
15
+ ## Registering services at Startup
16
+
17
+ ``` csharp
18
+ public Startup (IConfiguration configuration )
19
+ {
20
+ Configuration = configuration ;
21
+ }
22
+
23
+ public IConfiguration Configuration { get ; }
24
+
25
+ public void ConfigureServices (IServiceCollection services )
26
+ {
27
+ var connectionString = Configuration .GetSection (" ConnectionStrings" ).GetValue <string >(" Default" );
28
+ services .AddMySqlHealthChecks (connectionString , " MySQL" );
29
+ }
30
+
31
+ // OMISSIS
32
+
33
+ public void Configure (WebApplication app )
34
+ {
35
+ // OMISSIS
36
+
37
+ app .UseEndpoints (endpoints =>
38
+ {
39
+ endpoints .MapControllers ();
40
+ endpoints .AddDatabaseHealthChecks (" /status" , false ); // Use the True parameter if access is to be in AllowAnonymous mode
41
+ }
42
+ }
43
+ ```
Original file line number Diff line number Diff line change
1
+ # Health Checks configuration for Postgresql database
2
+
3
+
4
+ ## Configuration to add to the appsettings.json file
5
+
6
+ ``` json
7
+ "ConnectionStrings" : {
8
+ "Default" : " Host=[SERVER];Port=5432;Database=[DATABASE];Username=[USERNAME];Password=[PASSWORD]"
9
+ },
10
+ ```
11
+
12
+ <b >Note:</b > The default port for Postgresql is 5432, but it can be changed as needed according to your needs.
13
+
14
+
15
+ ## Registering services at Startup
16
+
17
+ ``` csharp
18
+ public Startup (IConfiguration configuration )
19
+ {
20
+ Configuration = configuration ;
21
+ }
22
+
23
+ public IConfiguration Configuration { get ; }
24
+
25
+ public void ConfigureServices (IServiceCollection services )
26
+ {
27
+ var connectionString = Configuration .GetSection (" ConnectionStrings" ).GetValue <string >(" Default" );
28
+ services .AddPostgresHealthChecks (connectionString , " Postgres" );
29
+ }
30
+
31
+ // OMISSIS
32
+
33
+ public void Configure (WebApplication app )
34
+ {
35
+ // OMISSIS
36
+
37
+ app .UseEndpoints (endpoints =>
38
+ {
39
+ endpoints .MapControllers ();
40
+ endpoints .AddDatabaseHealthChecks (" /status" , false ); // Use the True parameter if access is to be in AllowAnonymous mode
41
+ }
42
+ }
43
+ ```
You can’t perform that action at this time.
0 commit comments