UKBatch.AspNetCore
0.2.2-alpha
dotnet add package UKBatch.AspNetCore --version 0.2.2-alpha
NuGet\Install-Package UKBatch.AspNetCore -Version 0.2.2-alpha
<PackageReference Include="UKBatch.AspNetCore" Version="0.2.2-alpha" />
<PackageVersion Include="UKBatch.AspNetCore" Version="0.2.2-alpha" />
<PackageReference Include="UKBatch.AspNetCore" />
paket add UKBatch.AspNetCore --version 0.2.2-alpha
#r "nuget: UKBatch.AspNetCore, 0.2.2-alpha"
#:package UKBatch.AspNetCore@0.2.2-alpha
#addin nuget:?package=UKBatch.AspNetCore&version=0.2.2-alpha&prerelease
#tool nuget:?package=UKBatch.AspNetCore&version=0.2.2-alpha&prerelease
UKBatch.AspNetCore
ASP.NET Core integration for UKBatch — a lightweight, pluggable batch/job orchestration library for .NET 8 and .NET 10.
This package adds three things to a UKBatch host running inside an ASP.NET Core application:
HttpContextenricher —JobExecution.TriggeredByis populated automatically fromHttpContext.User.Identity.Name(with asub-claim fallback) when a job is triggered from inside a request handler.- W3C trace propagation — the ambient
Activityis captured at trigger time and can be restored inside the job viaJobContext.RestoreRequestActivity()so logs and child spans correlate with the originating HTTP request. - Readiness
IHealthCheck— registered under the name"ukbatch"with tags["ukbatch", "ready"]; signalsHealthyonce the runtime has started.
Quick start
var builder = WebApplication.CreateBuilder(args);
builder.AddUKBatchAspNetCore(b =>
{
b.AddJob<MyJob>();
});
var app = builder.Build();
app.MapHealthChecks("/healthz");
app.Run();
REQUIRED — opt in to trace correlation via RestoreRequestActivity
Without this single line at the top of your IJob.ExecuteAsync, the runtime cannot correlate logs and child spans with the originating HTTP request — trace propagation is opt-in by design.
public sealed class MyJob : IJob
{
public async Task ExecuteAsync(JobContext ctx, CancellationToken ct)
{
using var _ = ctx.RestoreRequestActivity(); // <-- REQUIRED for trace correlation
ctx.Logger.LogInformation("triggered by {TriggeredBy}", ctx.TriggeredBy);
await DoWorkAsync(ct);
}
}
Triggering from a request handler
Resolve IJobRunner, IJobTriggerContext, and IJobTraceContext from DI and call TriggerWithRequestContextAsync:
app.MapGet("/trigger/hello",
async (IJobRunner runner, IJobTriggerContext idCtx, IJobTraceContext traceCtx, CancellationToken ct) =>
{
var execution = await runner.TriggerWithRequestContextAsync(
idCtx, traceCtx, jobName: "MyJob", JobParameters.Empty, ct);
return Results.Ok(new { execution.ExecutionId, execution.TriggeredBy });
});
The same shape exists for batches via TriggerBatchWithRequestContextAsync.
Health check
AddUKBatchAspNetCore registers a readiness signal:
HealthyafterIHostApplicationLifetime.ApplicationStartedfires.Unhealthyduring startup.
It is tagged "ready" (not "live") — wire it as a Kubernetes readiness probe.
License
MIT. See LICENSE in the repo root. Full docs: nspukcode-hub.github.io/UKBatch · GitHub.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Cronos (>= 0.10.0)
- Polly (>= 8.5.0)
- UKBatch.Core (>= 0.2.2-alpha)
-
net8.0
- Cronos (>= 0.10.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Options (>= 10.0.0)
- Polly (>= 8.5.0)
- UKBatch.Core (>= 0.2.2-alpha)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on UKBatch.AspNetCore:
| Package | Downloads |
|---|---|
|
UKBatch.Api
REST API + OpenAPI 3.1 schema + SignalR push hub for UKBatch. Mounts under any RouteGroupBuilder via MapUKBatchApi. Auth-agnostic — call RequireAuthorization to opt in. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.2.2-alpha | 68 | 6/18/2026 |
| 0.2.1-alpha | 61 | 6/15/2026 |
| 0.2.0-alpha | 60 | 6/14/2026 |
| 0.1.6-alpha | 62 | 6/13/2026 |
| 0.1.5-alpha | 67 | 6/12/2026 |
| 0.1.4-alpha | 60 | 6/10/2026 |
| 0.1.3-alpha | 64 | 6/8/2026 |
| 0.1.1-alpha | 60 | 6/8/2026 |
| 0.1.0-alpha | 65 | 6/6/2026 |