public async Task <HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default) { try { var indexes = await _searchClient.ListIndexesAsync().ConfigureAwait(false); var indexNames = "Indexes Available:" + string.Join(",", indexes); return(new HealthCheckResult(HealthStatus.Healthy, indexNames, null, null)); } #pragma warning disable CA1031 // Do not catch general exception types catch (Exception ex) { return(new HealthCheckResult(HealthStatus.Unhealthy, "ListIndexesAsync threw Exception", ex, new Dictionary <string, object> { { "Search", ex.ToString() } })); } #pragma warning restore CA1031 // Do not catch general exception types }