health check fix

This commit is contained in:
Oliver Kieselbach
2026-05-10 23:16:30 +02:00
parent 7da5d482f1
commit c101eda796
4 changed files with 30 additions and 11 deletions
@@ -1 +1 @@
652
653
@@ -1 +1 @@
1285
1286
@@ -1,4 +1,5 @@
using System.Net;
using AutopilotMonitor.Functions.Helpers;
using AutopilotMonitor.Functions.Services;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
@@ -99,6 +100,14 @@ namespace AutopilotMonitor.Functions.Functions.Infrastructure
// Perform comprehensive health checks
var healthCheckResult = await _healthCheckService.PerformAllChecksAsync();
// SignalR Quota check exposes the subscription/resource-group path of the
// backing SignalR resource — restrict to Global Admins. Non-GA callers
// (Tenant Admins, Operators) get the rest of the report unchanged.
var requestCtx = context.GetRequestContext();
var visibleChecks = requestCtx.IsGlobalAdmin
? healthCheckResult.Checks
: healthCheckResult.Checks.Where(c => c.Name != "SignalR Quota").ToList();
// Always return 200 OK with the health status in the body
// This allows the frontend to properly display the results even if some checks fail
var response = req.CreateResponse(HttpStatusCode.OK);
@@ -107,7 +116,7 @@ namespace AutopilotMonitor.Functions.Functions.Infrastructure
service = "Autopilot Monitor API",
timestamp = healthCheckResult.Timestamp,
overallStatus = healthCheckResult.OverallStatus,
checks = healthCheckResult.Checks,
checks = visibleChecks,
version = _buildInfo.Version,
commitHash = _buildInfo.CommitHash,
buildUtc = _buildInfo.BuildUtc
@@ -346,14 +346,24 @@ export default function HealthCheckPage() {
<div className="mt-4 bg-gray-50 dark:bg-gray-700/50 rounded-lg p-3 border border-gray-200 dark:border-gray-600">
<h4 className="text-xs font-semibold text-gray-500 uppercase mb-2">Details</h4>
<dl className="space-y-1">
{Object.entries(check.details).map(([key, value]) => (
<div key={key} className="flex justify-between text-xs">
<dt className="font-medium text-gray-600 dark:text-gray-400">{key}</dt>
<dd className="text-gray-900 dark:text-gray-100 font-mono">
{Array.isArray(value) ? value.join(', ') : typeof value === 'object' ? JSON.stringify(value) : String(value)}
</dd>
</div>
))}
{Object.entries(check.details).map(([key, value]) => {
const isResourceId = key === 'Resource' && typeof value === 'string' && value.startsWith('/subscriptions/');
return (
<div key={key} className="flex justify-between text-xs items-center gap-3">
<dt className="font-medium text-gray-600 dark:text-gray-400 shrink-0">{key}</dt>
<dd className="text-gray-900 dark:text-gray-100 font-mono text-right break-all">
{isResourceId ? (
<span
title={String(value)}
className="inline-flex items-center px-2 py-0.5 rounded-full text-[11px] font-medium bg-green-100 text-green-800 dark:bg-green-900/40 dark:text-green-400 cursor-help"
>
Set
</span>
) : Array.isArray(value) ? value.join(', ') : typeof value === 'object' ? JSON.stringify(value) : String(value)}
</dd>
</div>
);
})}
</dl>
</div>
)}