In this article we will understand how to add a health check for SQL server database from .NET core web api application.
In this article we will perform below activities.
"Create TABLE Employee (Id int PRIMARY KEY IDENTITY(1,1), FirstName nvarchar(50), LastName nvarchar(50))"
Now we have an application which depends on SQL DB. This application is said to be helathy if the application can connect to SQL DB. Let's add a health check to verify the connectivity of the SQL DB
Install the package using the command dotnet add package AspNetCore.HealthChecks.SqlServer
Run the application and navigate to "healthz" endpoint
In this article we have learnt about adding health check for SQL DB in .NET core application. Let me know your thoughts in the comments.
The github repo link for the code changes made in this article is here