Version v1.0 · dotnet

Quick Start

Fastest path to a running scheduled DurableStack job with explicit C# configuration.

Quick Start

This is the fastest path to a running recurring job using PostgreSQL.

All configuration is set in C#.

Supported runtime targets: .NET 9 and .NET 10.

1) Install package

dotnet add package DurableStack.Hosting

2) Create a recurring job

using DurableStack.Core.Abstractions;
using DurableStack.Core.Models;
using DurableStack.Hosting.DependencyInjection;

[DurableJob(Name = "heartbeat-every-minute", MaxAttempts = 3)]
[RecurringJob("* * * * *", TimeZone = "UTC")]
public sealed class HeartbeatJob : IDurableJob
{
    public Task ExecuteAsync(JobContext context, CancellationToken cancellationToken = default)
    {
        Console.WriteLine($"Heartbeat from run {context.RunId}");
        return Task.CompletedTask;
    }
}

3) Configure DurableStack in Program.cs

using DurableStack.Core.Abstractions;
using DurableStack.Core.Options;
using DurableStack.Hosting.DependencyInjection;

var builder = WebApplication.CreateBuilder(args);
var connectionString = "REAL_CONNECTION_STRING";

builder.Services.AddDurableStackPostgres(connectionString, options =>
{
    // Poll jitter is enabled by default; tune ratio or disable explicitly if needed.
    options.PollJitterRatio = 0.2;
    // options.PollJitterEnabled = false;

    // Optional hosted observability
    options.Eventing.TenantId = null;
    options.Eventing.ClientSecret = null;
});

var app = builder.Build();

app.Run();

4) Run and verify

  • Run the app.
  • Wait one minute.
  • Confirm HeartbeatJob runs in application logs.

5) Optional: enable hosted observability

Set these two values in the same AddDurableStackPostgres options block:

  • options.Eventing.TenantId = "your-tenant-id";
  • options.Eventing.ClientSecret = "your-client-secret";

When both are set, event ingestion is enabled automatically and posted ingestion data includes runtime information.

Continue