Orchardcore health checks

From CrestApps/CrestApps.AgentSkills · View interactive version

Orchardcore health checks is an AI agent skill from the GitHub repository CrestApps/CrestApps.AgentSkills. Skill for exposing and extending Orchard Core tenant health checks. Covers HealthChecksOptions, the OrchardCore HealthChecks configuration section, health endpoint configuration, compact and detailed status codes, rate limiting probes, IHealthCheck registration, detailed JSON responses, IHealthCheck

How to use this skill

Skill file

Orchard Core Health Checks - Prompt Templates

Expose Tenant Health Checks

You are an Orchard Core expert. Generate health endpoint configuration and ASP.NET Core health check integrations for Orchard Core.

Guidelines

Enabling Health Checks

{
  "steps": [
    {
      "name": "Feature",
      "enable": [
        "OrchardCore.HealthChecks"
      ],
      "disable": []
    }
  ]
}

Tenant Configuration

The module binds HealthChecksOptions from OrchardCore:HealthChecks.

{
  "OrchardCore": {
    "HealthChecks": {
      "Url": "/health/live",
      "ShowDetails": false
    }
  }
}
OrchardCore__HealthChecks__Url=/health/live
OrchardCore__CustomerA__HealthChecks__Url=/health/ready

The second variable targets only the CustomerA tenant.

| Option | Default | Description |

|---|---|---|

| Url | /health/live | Tenant health endpoint path. |

| ShowDetails | false | Enables the detailed JSON response writer. |

Use the shell or tenant configuration source appropriate to the hosting model so the settings apply to the intended tenant.

Registering a Custom Health Check

Register custom checks in a module startup class. The Health Checks feature already calls AddHealthChecks; calling it again returns the same builder for adding checks. Use [RequireFeatures("OrchardCore.HealthChecks")] so the registration loads only when the endpoint exists, or declare the feature as a dependency.

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using OrchardCore.Modules;

namespace MyModule;

[RequireFeatures("OrchardCore.HealthChecks")]
public sealed class Startup : StartupBase
{
    public override void ConfigureServices(IServiceCollection services)
    {
        services
            .AddHealthChecks()
            .AddCheck<InventoryHealthCheck>("inventory");
    }
}
using Microsoft.Extensions.Diagnostics.HealthChecks;

namespace MyModule;

public sealed class InventoryHealthCheck : IHealthCheck
{
    private readonly IInventoryClient _inventoryClient;

    public InventoryHealthCheck(IInventoryClient inventoryClient)
    {
        _inventoryClient = inventoryClient;
    }

    public async Task<HealthCheckResult> CheckHealthAsync(
        HealthCheckContext context,
        CancellationToken cancellationToken = default)
    {
        var isAvailable = await _inventoryClient.IsAvailableAsync(cancellationToken);

        return isAvailable
            ? HealthCheckResult.Healthy("Inventory service is reachable.")
            : HealthCheckResult.Unhealthy("Inventory service is unavailable.");
    }
}

Detailed Response Format

When ShowDetails is true, DefaultHealthChecksResponseWriter produces JSON shaped like:

{
  "Status": "Healthy",
  "Duration": "00:00:00.0123456",
  "HealthChecks": [
    {
      "Name": "inventory",
      "Status": "Healthy",
      "Description": "Inventory service is reachable."
    }
  ]
}

The response writer uses HealthReport.TotalDuration and every HealthReportEntry from the health report.

Replacing the Response Writer

Register a custom scoped IHealthChecksResponseWriter only when the detailed contract must change.

using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using OrchardCore.HealthChecks.Services;

namespace MyModule;

public sealed class ProbeResponseWriter : IHealthChecksResponseWriter
{
    public async Task WriteResponseAsync(HttpContext context, HealthReport report)
    {
        context.Response.ContentType = "application/json";
        await context.Response.WriteAsJsonAsync(new
        {
            status = report.Status.ToString(),
        });
    }
}
services.Replace(ServiceDescriptor.Scoped<IHealthChecksResponseWriter, ProbeResponseWriter>());

The writer is only used when ShowDetails is true; compact mode keeps the ASP.NET Core default writer.

Probe Design

Troubleshooting

| Symptom | Check |

|---|---|

| Endpoint is missing (404) | Enable OrchardCore.HealthChecks for the tenant and include the tenant host and URL prefix. |

| Wrong endpoint path | Check OrchardCore:HealthChecks:Url in tenant configuration, then reload the tenant. |

| JSON details are absent | Set ShowDetails to true. |

| Unhealthy response has HTTP 200 | This is expected with detailed output; evaluate the JSON Status. |

| Custom check never runs | Verify it is registered with AddHealthChecks().AddCheck in a feature enabled on the same tenant. |

| Probe returns 429 | A Rate Limits policy (global or endpoint) is throttling the probe; exclude or raise its budget. |

Upgrading from 3.x

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.