Xabaril / AspNetCore.Diagnostics.HealthChecks

Enterprise HealthChecks for ASP.NET Core Diagnostics Package
Apache License 2.0
4.12k stars 800 forks source link

AddAzureServiceBusQueue relies on the knowledge queues and topics exist #2321

Open sebastienros opened 1 week ago

sebastienros commented 1 week ago

While adding Service Bus emulator support for Aspire (https://github.com/dotnet/aspire/pull/6737) I faced the issue to have to create health checks on the configured queues and topics, but not be able to conditionally add these health checks.

What happens is that we can correctly pass a lambda in the health checks registrations to provide the name of a queue or a topic, but if there are no queues or no topics then we have registered a health check and nothing to provide. The same way we can't provide multiple health checks (several queues or several topics).

How I solved it is by creating a custom health check that accepts a factory for a list of queues/topics instead. Technically the only difference would be that the current factories would return a list of values, potentially empty, instead of exactly one value which can't be null.