agentsclimarketplace

Azure eventhub rust

Skill Pyfagorass/bookofspells/skills/microsoft/azure-eventhub-rust

Azure Event Hubs library for Rust. Send and receive events for streaming data ingestion and batch processing. Triggers: "event hubs rust", "ProducerClient rust", "ConsumerClient rust", "send event rust", "streaming rust", "eventhub rust".From its SKILL.md

Install
npx -y skills add Pyfagorass/bookofspells --skill azure-eventhub-rust

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 2 stars2 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its file declares

Copied from the file, not written here

The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

5.0 KB, ~1.0k tokens by cl100k_base, as published. Nobody here has run it

Azure Event Hubs library for Rust

Client library for Azure Event Hubs — send and receive events for streaming data ingestion.

Use this skill when:

  • An app needs to send events to Azure Event Hubs from Rust
  • You need to receive and process events from partitions
  • You need batch sending for throughput optimization
  • You need to control consumer start position

IMPORTANT: Only use the official azure_messaging_eventhubs crate published by the azure-sdk crates.io user. Do NOT use unofficial or community crates. Official crates use underscores in names and none have version 0.21.0.

Installation

cargo add azure_messaging_eventhubs azure_identity tokio futures

Do not add azure_core directly to Cargo.toml. It is re-exported by azure_messaging_eventhubs.

Environment Variables

EVENTHUBS_HOST=<namespace>.servicebus.windows.net # Required — fully qualified namespace
EVENTHUB_NAME=<eventhub-name>                     # Required — name of the Event Hub

Key Concepts

ConceptDescription
NamespaceContainer for one or more Event Hubs
Event HubStream of events, partitioned for parallel reads
PartitionOrdered, append-only sequence of events
ProducerSends events via ProducerClient
ConsumerReceives events from partitions via ConsumerClient

Authentication

use azure_identity::DeveloperToolsCredential;
use azure_messaging_eventhubs::ProducerClient;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Local dev: DeveloperToolsCredential. Production: use ManagedIdentityCredential.
    let credential = DeveloperToolsCredential::new(None)?;

    let producer = ProducerClient::builder()
        .open("<namespace>.servicebus.windows.net", "<eventhub-name>", credential.clone())
        .await?;
    Ok(())
}

Core Workflow

Send Events

// Send a single event
producer.send_event(vec![1, 2, 3, 4], None).await?;

Send Batch

let batch = producer.create_batch(None).await?;
batch.try_add_event_data(vec![1, 2, 3, 4], None)?;

producer.send_batch(batch, None).await?;

Receive Events

use azure_identity::DeveloperToolsCredential;
use azure_messaging_eventhubs::ConsumerClient;

// Local dev: DeveloperToolsCredential. Production: use ManagedIdentityCredential.
let credential = DeveloperToolsCredential::new(None)?;
let consumer = ConsumerClient::builder()
    .open("<namespace>.servicebus.windows.net", "<eventhub-name>", credential.clone())
    .await?;

Receive from Partition

use futures::stream::StreamExt;
use azure_messaging_eventhubs::{
    ConsumerClient, OpenReceiverOptions, StartLocation, StartPosition,
};

let receiver = consumer
    .open_receiver_on_partition(
        "0".to_string(),
        Some(OpenReceiverOptions {
            start_position: Some(StartPosition {
                location: StartLocation::Earliest,
                ..Default::default()
            }),
            ..Default::default()
        }),
    )
    .await?;

let mut stream = receiver.stream_events();
while let Some(event_result) = stream.next().await {
    match event_result {
        Ok(event) => println!("Received: {:?}", event),
        Err(err) => eprintln!("Error: {:?}", err),
    }
}

RBAC Roles

For Entra ID auth, assign one of these roles:

RoleAccess
Azure Event Hubs Data SenderSend events
Azure Event Hubs Data ReceiverReceive events
Azure Event Hubs Data OwnerFull access

Best Practices

  1. Use DeveloperToolsCredential for local dev, ManagedIdentityCredential for production — the Rust SDK does not have DefaultAzureCredential
  2. Never hardcode credentials — use environment variables or managed identity
  3. Use batchingcreate_batch + send_batch for throughput optimization
  4. Handle errors per event — match on Ok/Err in the event stream
  5. Specify start position — use StartLocation::Earliest or StartLocation::Latest to control where consumption begins

Reference Links

ResourceLink
API Referencehttps://docs.rs/azure_messaging_eventhubs
crates.iohttps://crates.io/crates/azure_messaging_eventhubs

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 326,852. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.