UKBatch.AspNetCore 0.2.2-alpha

This is a prerelease version of UKBatch.AspNetCore.
dotnet add package UKBatch.AspNetCore --version 0.2.2-alpha
                    
NuGet\Install-Package UKBatch.AspNetCore -Version 0.2.2-alpha
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="UKBatch.AspNetCore" Version="0.2.2-alpha" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="UKBatch.AspNetCore" Version="0.2.2-alpha" />
                    
Directory.Packages.props
<PackageReference Include="UKBatch.AspNetCore" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add UKBatch.AspNetCore --version 0.2.2-alpha
                    
#r "nuget: UKBatch.AspNetCore, 0.2.2-alpha"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package UKBatch.AspNetCore@0.2.2-alpha
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=UKBatch.AspNetCore&version=0.2.2-alpha&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=UKBatch.AspNetCore&version=0.2.2-alpha&prerelease
                    
Install as a Cake Tool

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:

  1. HttpContext enricherJobExecution.TriggeredBy is populated automatically from HttpContext.User.Identity.Name (with a sub-claim fallback) when a job is triggered from inside a request handler.
  2. W3C trace propagation — the ambient Activity is captured at trigger time and can be restored inside the job via JobContext.RestoreRequestActivity() so logs and child spans correlate with the originating HTTP request.
  3. Readiness IHealthCheck — registered under the name "ukbatch" with tags ["ukbatch", "ready"]; signals Healthy once 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:

  • Healthy after IHostApplicationLifetime.ApplicationStarted fires.
  • Unhealthy during 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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