AspNetCore.Diagnostics.HealthChecks
AspNetCore.Diagnostics.HealthChecks copied to clipboard
Azure.IoTHub Creates a new ServiceClient causing socket exhaustion
What happened:
IoTHubHealthCheck
Creates a new ServiceClient
, this is a problem, see: https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.devices.serviceclient?view=azure-dotnet#remarks
Also currently there is no way to use managed identity to connect to iothub, only connection strings are possible. Would be better if this works the same as eg: Azure.Data.Tables where you can inject the clients using already registered services.
Same goes for the RegistryManager https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.devices.registrymanager?view=azure-dotnet#remarks
What you expected to happen:
Keep the Azure apis consistent
eg:
.AddIotHub(sp => sp.GetService<ServiceClient>(), sp => sp.GetService<RegistryManager>(), options => ...
Maybe split it per check, or handle clients being null if they aren't needed depending on the options.
How to reproduce it (as minimally and precisely as possible):
register the current AddIotHub
and monitor for socket exhaustion.
Source code sample: https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks/blob/master/src/HealthChecks.Azure.IoTHub/IoTHubHealthCheck.cs#L43 #
Anything else we need to know?:
Environment:
- .NET Core version : 8
- Healthchecks version: 8.0.1
- Operative system: linux
- Others: