#sdk #azure #amqp #cloud #eventhubs


An unofficial AMQP 1.0 rust client for Azure Event Hubs

13 unstable releases (3 breaking)

new 0.16.0 Sep 28, 2023
0.15.1 Sep 24, 2023
0.14.4 Sep 13, 2023
0.14.0 Aug 31, 2023
0.1.0 Apr 25, 2023

#131 in Web programming

Download history 4/week @ 2023-06-09 7/week @ 2023-06-16 3/week @ 2023-06-23 3/week @ 2023-06-30 2/week @ 2023-07-07 5/week @ 2023-07-14 3/week @ 2023-07-21 2/week @ 2023-07-28 43/week @ 2023-08-04 38/week @ 2023-08-11 18/week @ 2023-08-18 86/week @ 2023-08-25 42/week @ 2023-09-01 98/week @ 2023-09-08 76/week @ 2023-09-15 58/week @ 2023-09-22

301 downloads per month

MIT license



An unofficial and experimental Azure Event Hubs client library for Rust.

This crate follows a similar structure to that of the Azure SDK for .Net, and thus it should be familiar to anyone who has used the dotnet SDK. This crate is still in development, and not all features are implemented yet.


Event Hub Producer Example

use azeventhubs::producer::{
EventHubProducerClient, EventHubProducerClientOptions, SendEventOptions,

async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut producer_client =
            "<CONNECTION_STRING>", // Replace with your connection string
            "<EVENT_HUB_NAME>".to_string(), // Replace with your hub name

    let partition_ids = producer_client.get_partition_ids().await?;

    let event = "Hello, world to first partition!";
    let options = SendEventOptions::new().with_partition_id(&partition_ids[0]);
    producer_client.send_event(event, options).await?;



Event Hub Consumer Example

use futures_util::StreamExt;
use azeventhubs::consumer::{EventHubConsumerClient, EventHubConsumerClientOptions, EventPosition, ReadEventOptions};

async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create a consumer client
    let mut consumer_client =
            "<CONNECTION_STRING>", // Replace with your connection string
            "<EVENT_HUB_NAME>".to_string(), // Replace with your hub name

    let partition_ids = consumer_client.get_partition_ids().await?;
    let starting_position = EventPosition::earliest();
    let options = ReadEventOptions::default();

    // Get a stream of events from the first partition
    let mut stream = consumer_client
        .read_events_from_partition(&partition_ids[0], starting_position, options)

    // Receive 30 events
    let mut counter = 0;
    while let Some(event) = stream.next().await {
        let event = event?;
        let body = event.body()?;
        let value = std::str::from_utf8(body)?;
        log::info!("{:?}", value);

        log::info!("counter: {}", counter);
        counter += 1;
        if counter > 30 {
    // Close the stream

    // Close the consumer client


What is implemented and what is not?

Feature Supported
Event Hub Connection Yes
Event Hub Producer Yes
Event Hub Consumer Yes
Partition Receiver Yes
Event Hub Buffered Producer Not yet
Event Hub Processor Not yet
Checkpoint Store Not yet

TLS Support

Communication between a client application and an Azure Service Event Hub namespace is encrypted using Transport Layer Security (TLS). The TLS implementation is exposed to the user through the corresponding feature flags (please see the feature flag section below). The user should ensure either the rustls or native-tls feature is enabled, and one and only one TLS implementation must be enabled. Enabling both features is not supported and will result in an error.

The native-tls feature is enabled by default, and it will use the native-tls crate to provide TLS support. The rustls feature will use the rustls crate and webpki-roots crate to provide TLS support.

Feature Flags

This crate supports the following feature flags:

Feature Description
default Enables "native-tls" feature
rustls Enables the use of the rustls crate for TLS support
native-tls Enables the use of the native-tls crate for TLS support

WebAssembly Support

WebAssembly is NOT supported yet.

License: MIT


~564K SLoC