|
1 | 1 | # Production Readiness and Deployment
|
2 | 2 |
|
3 | 3 | ## Adding EF Healthchecks to the BackEnd
|
4 |
| -1. Add a package reference to **Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore** version 2.2.0. |
| 4 | +1. Add a reference to the NuGet package `Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore` version `2.2.0`. |
| 5 | + > This can be done from the command line using `dotnet add package Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore --version 2.2.0` |
5 | 6 | 1. Add a DbContext health check in `Startup.cs` by adding the following code to `ConfigureServices`:
|
6 | 7 | ```csharp
|
7 | 8 | services.AddHealthChecks()
|
|
11 | 12 | 1. Test the end point by navigating to `/health`, it should return the text `Healthy`.
|
12 | 13 |
|
13 | 14 | ## Adding EF Healthchecks to the FrontEnd
|
14 |
| -1. Add a package reference to **Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore** version 2.2.0. |
| 15 | +1. Add a reference to the NuGet package `Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore` version `3.0.0-preview6.19307.2`. |
| 16 | + > This can be done from the command line using `dotnet add package Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore --version 3.0.0-preview6.19307.2` |
| 17 | +
|
| 18 | + > Note: The `FrontEnd` and `BackEnd` projects have different versions of this package because they reference different versions of EntityFrameworkCore. |
15 | 19 | 1. Add a DbContext health check in `Startup.cs` by adding the following code to `ConfigureServices`:
|
16 | 20 | ```csharp
|
17 | 21 | services.AddHealthChecks()
|
|
21 | 25 | 1. Test the end point by navigating to `/health`, it should return the text `Healthy`.
|
22 | 26 |
|
23 | 27 | ## Adding a custom health check to test for BackEnd availability
|
24 |
| -1. Add a `Task<bool> CheckHealthAsync()` method to `IApiClient`. |
| 28 | +1. Add a `CheckHealthAsync` method to `IApiClient`. |
| 29 | + ```c# |
| 30 | + public interface IApiClient |
| 31 | + { |
| 32 | + ... |
| 33 | + Task<bool> CheckHealthAsync(); |
| 34 | + } |
| 35 | + ``` |
25 | 36 | 1. Implement the `CheckHealthAsync` method in `ApiClient` by adding the following code:
|
26 | 37 | ```csharp
|
27 | 38 | public async Task<bool> CheckHealthAsync()
|
|
76 | 87 | ```csharp
|
77 | 88 | services.AddHealthChecks()
|
78 | 89 | .AddCheck<BackendHealthCheck>("backend")
|
79 |
| - .AddDbContextCheck<IdentityDbContext>(); |
| 90 | + .AddDbContextCheck<IdentityDbContext>(); |
80 | 91 | ```
|
81 | 92 | 1. Test the end point by navigating to `/health`, it should return the text `Healthy`.
|
82 | 93 |
|
|
0 commit comments