azure-eventhub-rust
Makes your agent send and receive events using Azure Event Hubs in Rust. It helps handle real-time data streams and collect events efficiently.
What it does
This code allows Rust programs to send and receive data (events) from a service called Azure Event Hubs. It's useful for collecting large amounts of real-time data.
When to use it
- ✓Sending lots of sensor data for analysis.
- ✓Receiving messages from other systems for processing.
- ✓Building a system that logs real-time activities.
Example of what to ask your AI
“How do I send a simple message to Azure Event Hubs using Rust?”
Want more? Open the sections below.
How to use
The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.
Skill link
Ready-to-paste message
How it works
You create a 'producer' to send events or a 'consumer' to receive them. The code connects to the Azure service and manages sending or receiving the data.
Installation
Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.
In the terminal (Claude Code, Codex, Cursor), in your project folder:
npx skills add sickn33/agentic-awesome-skills --skill azure-eventhub-rustOr download just the file:
curl -L https://raw.githubusercontent.com/sickn33/agentic-awesome-skills/main/plugins/agentic-awesome-skills-claude/skills/azure-eventhub-rust/SKILL.md -o SKILL.mdTechnical content (original SKILL.md)
Original text by the author, straight from GitHub.
Azure Event Hubs SDK for Rust
Client library for Azure Event Hubs — big data streaming platform and event ingestion service.
The examples below require a reviewed compatible crate set and replacement of every resource placeholder. Do not use production data for demonstration writes.
Installation
cargo add azure_messaging_eventhubs@=0.16.0 azure_identity@=1.1.0-beta.1 azure_core@=1.2.0-beta.1
Environment Variables
export EVENTHUBS_HOST="<namespace>.servicebus.windows.net"
export EVENTHUB_NAME="<eventhub-name>"
Key Concepts
- Namespace — container for Event Hubs
- Event Hub — stream of events partitioned for parallel processing
- Partition — ordered sequence of events
- Producer — sends events to Event Hub
- Consumer — receives events from partitions
Producer Client
Create Producer
use azure_identity::DeveloperToolsCredential;
use azure_messaging_eventhubs::ProducerClient;
let credential = DeveloperToolsCredential::new(None)?;
let producer = ProducerClient::builder()
.open("<namespace>.servicebus.windows.net", "eventhub-name", credential.clone())
.await?;
Send Single Event
producer.send_event(vec![1, 2, 3, 4], None).await?;
Send Batch
let batch = producer.create_batch(None).await?;
if !batch.try_add_event_data(b"event 1".to_vec(), None)? {
return Err("Event does not fit in the batch".into());
}
if !batch.try_add_event_data(b"event 2".to_vec(), None)? {
return Err("Send the existing batch and retry the remaining event in a new batch".into());
}
producer.send_batch(batch, None).await?;
Consumer Client
Create Consumer
use azure_messaging_eventhubs::ConsumerClient;
let credential = DeveloperToolsCredential::new(None)?;
let consumer = ConsumerClient::builder()
.open("<namespace>.servicebus.windows.net", "eventhub-name", credential.clone())
.await?;
Receive Events
// Open receiver for specific partition
use futures::StreamExt;
let receiver = consumer.open_receiver_on_partition("0".to_string(), None).await?;
let mut events = receiver.stream_events();
// Bound the receive loop and handle the no-event timeout without logging payloads.
for _ in 0..100 {
match tokio::time::timeout(std::time::Duration::from_secs(10), events.next()).await {
Ok(Some(Ok(event))) => { /* process the authorized event and checkpoint safely */ }
Ok(Some(Err(error))) => return Err(error.into()),
Ok(None) | Err(_) => break,
}
}
Get Event Hub Properties
let properties = consumer.get_eventhub_properties(None).await?;
println!("Partitions: {:?}", properties.partition_ids);
Get Partition Properties
let partition_props = consumer.get_partition_properties("0", None).await?;
println!("Last sequence number: {}", partition_props.last_enqueued_sequence_number);
Best Practices
- Reuse clients — create once, send many events
- Use batches — more efficient than individual sends
- Check batch capacity —
try_add_event_datareturns false when full - Process partitions in parallel — each partition can be consumed independently
- Use consumer groups — isolate different consuming applications
- Handle checkpointing — use
azure_messaging_eventhubs_checkpointstore_blobfor distributed consumers
Checkpoint Store (Optional)
For distributed consumers with checkpointing:
cargo add azure_messaging_eventhubs_checkpointstore_blob
Event Hubs 0.16 uses the Azure core beta line, so pair it with the published matching identity beta; do not mix credential traits from the stable core line.
The reviewed example set uses azure_messaging_eventhubs 0.16.0 and compatible Azure core/credential crates. Record and commit Cargo.lock; source/API review is not a compiler or live-service test.
Reference Links
| Resource | Link |
|---|---|
| API Reference | https://docs.rs/azure_messaging_eventhubs |
| Source Code | https://github.com/Azure/azure-sdk-for-rust/tree/main/sdk/eventhubs/azure_messaging_eventhubs |
| crates.io | https://crates.io/crates/azure_messaging_eventhubs |
When to Use
Use when a Rust application publishes individual/batched events or consumes a specific Event Hubs partition with an explicit consumer group and checkpoint policy.
Limitations
…
FAQ
What is a 'Namespace' or 'Event Hub'?
A Namespace is like a container for your Event Hubs. An Event Hub is a data stream where events are organized into partitions.
What are 'Producer' and 'Consumer'?
A Producer is who sends events to the Event Hub. A Consumer is who reads events from a specific partition.
Can I send multiple events at once?
Yes, you can group multiple events into a 'batch' to send more efficiently.
Details
Original description by the author
Azure Event Hubs SDK for Rust. Use for sending and receiving events, streaming data ingestion.
Popularity
- GitHub stars
- 48k
- Ranking position
- #2316
- License
- MIT
- Updated
- 10/15/2026
Comments
- …
More skills from this repository
00-andruia-consultant
Helps your agent start or improve AI projects. It analyzes code, suggests tools, and creates action plans in Spanish.
sickn33/agentic-awesome-skills
007
Lets your agent perform security audits and threat modeling. It's useful for protecting projects against attacks and vulnerabilities.
sickn33/agentic-awesome-skills
10-andruia-skill-smith
Helps your agent create or improve AI tools. It defines how tools work, writes documentation, and validates the structure.
sickn33/agentic-awesome-skills
20-andruia-niche-intelligence
Lets your agent create a summary about a specific industry. It's useful for understanding the context, rules, usage patterns, and risks of a project, using reliable sources.
sickn33/agentic-awesome-skills
Similar skills
api-connector-builder
Has your agent build new API connections following the existing pattern. Use when you need to add one more integration without creating a new way of doing things.
affaan-m/ECC
api-design
Helps your agent design REST APIs following best practices. It's useful for defining how APIs communicate, how errors are shown, and how to organize data.
affaan-m/ECC
backend-patterns
Helps your agent with server-side architecture patterns and database optimization. It's useful for building or reviewing code that runs on the server.
affaan-m/ECC