I have this setup for a HealthCheck for a WCF SOAP service and for some reason the code in the second delegate is not executed. If I put breakpoint it's not hit also in debug.
HealthCheckConfiguration healthCheckConfiguration = new ();
configureHealthChecks.Invoke(healthCheckConfiguration);
services
.AddHealthChecks()
.AddUrlGroup(
(uriOptions) => uriOptions.UseHttpMethod(HttpMethod.Head),
healthCheckConfiguration.Name,
healthCheckConfiguration.FailureStatus,
healthCheckConfiguration.Tags,
healthCheckConfiguration.Timeout,
(serviceProvider, httpClient) =>
{
var config = serviceProvider.GetRequiredService<IOptionsMonitor<TSettings>>();
httpClient.BaseAddress = new($"{config.CurrentValue.Endpoint}?wsdl");
});
The similar delegate in the second sample is hit and is working correctly, but we want to change the request for the HealthCheck from GET to HEAD.
services
.AddHealthChecks()
.AddUrlGroup(
(services) =>
{
var config = services.GetRequiredService<IOptionsMonitor<TSettings>>();
return new Uri($"{config.CurrentValue.Endpoint}?wsdl");
},
healthCheckConfiguration.Name,
healthCheckConfiguration.FailureStatus,
healthCheckConfiguration.Tags,
healthCheckConfiguration.Timeout);
Try a custom check: