Run Orleans Journaling samples
The Journaling with Azure Blob JSON sample exercises the experimental Journaling programming model end to end. It uses .NET Aspire and the Azure Storage emulator and runs with local emulator credentials.
The sample demonstrates:
- IDurableDictionary<T, U>, IDurableList<T>, IDurableQueue<T>, and IDurableSet<T>.
- IDurableValue<T>, journal-backed IPersistentState<T>, and IDurableTaskCompletionSource<T>.
- JSON source-generation metadata for all journaled payload types.
- Azure Blob WAL and checkpoint name customization.
- An acknowledged write, grain deactivation, reactivation, and recovered-state verification.
- Inspection of the raw JSON Lines journal.
Run with Aspire
Section titled “Run with Aspire”Install the .NET SDK, the Aspire CLI, and a Docker-compatible container runtime. From the sample directory, run:
aspire run --project JournalingAzureBlobJson.AppHostThe app host starts the Azure Storage emulator and the sample service. The service writes every built-in durable state category, deactivates the grain, verifies the recovered values on a new activation, and prints the stored JSON Lines.
Run the Redis sample
Section titled “Run the Redis sample”The compiled Redis Journaling sample configures Redis, writes an IDurableValue<T>, deactivates the grain, and verifies recovery on a new activation:
public sealed class RedisJournalCounterGrain( [FromKeyedServices("count")] IDurableValue<int> count) : DurableGrain, IRedisJournalCounterGrain{ private readonly Guid _activationId = Guid.NewGuid();
public async ValueTask<CounterSnapshot> Increment() { count.Value++; await WriteStateAsync(); return GetCurrentSnapshot(); }
public ValueTask<CounterSnapshot> GetSnapshot() => ValueTask.FromResult(GetCurrentSnapshot());
public ValueTask Deactivate() { DeactivateOnIdle(); return ValueTask.CompletedTask; }
private CounterSnapshot GetCurrentSnapshot() => new(_activationId, count.Value);}Start a local Redis server, then run the sample from the repository root:
dotnet run --project docs/site/src/content/docs/grains/journaling/snippets/redis-journaling -- "localhost:6379"Pass a StackExchange.Redis connection string as the first argument when Redis is available at another endpoint. The sample uses the isolated key prefix journaling-docs-sample. Configure Redis persistence and replication before evaluating server-restart recovery.
