Reputation: 21
I am try Aspire and get very confused about Health Checks. All blogs and articles copy same code from NET Aspire documentation what just not enought.
NET Aspire documentation has two case:
What I am wanted? A way to show MyProcess state in NET Aspire Dashboard similar to Redis cache process in Net Aspire App template sample.
I am decompiled AddRedis() and found what they register Health Check within AppHost and try to connect to database.
Unfortunate I am can not consider this approach as universal or preferable because not all situation can be checked from AppHost. For example: access to resources (relative path file) from dockered MyProcess.
How to do it right way? May be create first Health Check in MyProcess and second Health Check in Apphost where call http://myprocess/health ?
Answer:
builder.Services
.AddHealthChecks()
.AddUrlGroup(new Uri("http://service"), "HealthPoint1")
var service = builder
.AddProject<Projects.X>("ProjectX")
.WithHealthCheck("HealthPoint1")
var service = builder
.AddProject<Projects.X>("ProjectX")
.WithHttpsEndpoint(name: "X")
.WithHttpsHealthCheck("/health", 200, "HealthPoint1");
Upvotes: 0
Views: 124