Microsoft.Orleans.Streaming.EventHubs 9.2.0-preview3

Prefix Reserved
This is a prerelease version of Microsoft.Orleans.Streaming.EventHubs.
dotnet add package Microsoft.Orleans.Streaming.EventHubs --version 9.2.0-preview3
                    
NuGet\Install-Package Microsoft.Orleans.Streaming.EventHubs -Version 9.2.0-preview3
                    
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="Microsoft.Orleans.Streaming.EventHubs" Version="9.2.0-preview3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Microsoft.Orleans.Streaming.EventHubs" Version="9.2.0-preview3" />
                    
Directory.Packages.props
<PackageReference Include="Microsoft.Orleans.Streaming.EventHubs" />
                    
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 Microsoft.Orleans.Streaming.EventHubs --version 9.2.0-preview3
                    
#r "nuget: Microsoft.Orleans.Streaming.EventHubs, 9.2.0-preview3"
                    
#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.
#addin nuget:?package=Microsoft.Orleans.Streaming.EventHubs&version=9.2.0-preview3&prerelease
                    
Install Microsoft.Orleans.Streaming.EventHubs as a Cake Addin
#tool nuget:?package=Microsoft.Orleans.Streaming.EventHubs&version=9.2.0-preview3&prerelease
                    
Install Microsoft.Orleans.Streaming.EventHubs as a Cake Tool

Microsoft Orleans Stream Provider for Azure Event Hubs

Introduction

Microsoft Orleans Stream Provider for Azure Event Hubs enables Orleans applications to leverage Azure Event Hubs for reliable, scalable event processing. This provider allows you to use Event Hubs as a streaming backbone for your Orleans application to both produce and consume streams of events.

Getting Started

To use this package, install it via NuGet:

dotnet add package Microsoft.Orleans.Streaming.EventHubs

Example - Configuring Event Hubs Stream Provider

using Microsoft.Extensions.Hosting;
using Orleans.Configuration;
using Orleans.Hosting;
namespace ExampleGrains;

var builder = Host.CreateApplicationBuilder(args)
    .UseOrleans(siloBuilder =>
    {
        siloBuilder
            .UseLocalhostClustering()
            // Configure Azure Event Hubs as a stream provider
            .AddEventHubStreams(
                "EventHubStreamProvider",
                configurator => 
                {
                    configurator.ConfigureEventHub(builder => builder.Configure(options => 
                    {
                        options.ConnectionString = "YOUR_EVENT_HUB_CONNECTION_STRING";
                        options.ConsumerGroup = "YOUR_CONSUMER_GROUP"; // Default is "$Default"
                        options.Path = "YOUR_EVENT_HUB_NAME";
                    }));
                    
                    configurator.UseAzureTableCheckpointer(builder => builder.Configure(options => 
                    {
                        options.ConnectionString = "YOUR_STORAGE_CONNECTION_STRING";
                        options.TableName = "EventHubCheckpoints"; // Optional
                    }));
                });
    });

// Run the host
await builder.RunAsync();

Example - Using Event Hub Streams in a Grain

// Grain interface
public interface IStreamProcessingGrain : IGrainWithGuidKey
{
    Task StartProcessing();
}

// Grain implementation
public class StreamProcessingGrain : Grain, IStreamProcessingGrain
{
    private IStreamProvider _streamProvider;
    private IAsyncStream<MyEvent> _stream;
    private StreamSubscriptionHandle<MyEvent> _subscription;

    public override async Task OnActivateAsync(CancellationToken cancellationToken)
    {
        // Get the stream provider
        _streamProvider = GetStreamProvider("EventHubStreamProvider");
        
        // Get a reference to a specific stream
        _stream = _streamProvider.GetStream<MyEvent>(this.GetPrimaryKey(), "MyStreamNamespace");
        
        await base.OnActivateAsync(cancellationToken);
    }

    public async Task StartProcessing()
    {
        // Subscribe to the stream to process events
        _subscription = await _stream.SubscribeAsync(OnNextAsync);
    }

    private Task OnNextAsync(MyEvent evt, StreamSequenceToken token)
    {
        Console.WriteLine($"Received event: {evt.Data}");
        return Task.CompletedTask;
    }

    // Produce an event to the stream
    public Task SendEvent(MyEvent evt)
    {
        return _stream.OnNextAsync(evt);
    }
}

// Event class

public class MyEvent
{
    public string Data { get; set; }
}

Documentation

For more comprehensive documentation, please refer to:

Feedback & Contributing

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 was computed.  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 Microsoft.Orleans.Streaming.EventHubs:

Package Downloads
Microsoft.AutoGen.RuntimeGateway.Grpc

A programming framework for agentic AI

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Microsoft.Orleans.Streaming.EventHubs:

Repository Stars
microsoft/project-oagents
Experimental AI Agents Framework
Version Downloads Last updated
9.2.0-preview3 278 6/10/2025
9.2.0-preview2 133 6/4/2025
9.2.0-preview1 3,165 4/4/2025
9.1.2 32,106 2/13/2025
9.0.1 36,546 11/23/2024
9.0.0 1,069 11/14/2024
8.2.0 62,901 7/12/2024
8.2.0-preview1 139 5/22/2024
8.1.0 23,080 4/17/2024
8.1.0-preview3 1,050 3/11/2024
8.1.0-preview2 115 2/23/2024
8.1.0-preview1 1,209 2/13/2024
8.0.0 11,426 1/5/2024
8.0.0-rc2 174 12/20/2023
8.0.0-rc1 169 12/4/2023
7.2.7 264 10/15/2024
7.2.6 924 3/9/2024
7.2.5 301 2/22/2024
7.2.4 9,548 12/2/2023
7.2.3 4,104 11/3/2023
7.2.2 815 10/16/2023
7.2.1 6,112 7/11/2023
7.2.0 2,787 7/7/2023
7.1.2 3,800 4/19/2023
7.1.1 4,230 3/23/2023
7.1.0 5,487 2/1/2023
7.0.0 10,511 11/8/2022
7.0.0-rc2 458 10/19/2022
4.0.0-preview2 654 8/4/2022
4.0.0-preview1 447 2/10/2022