Azure Eventhub Rust
MicrosoftOfficialCreated by Microsoft
- Skill
- Tool integration
- Cloud and DevOps
- MIT
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides guidance on using the official Azure Event Hubs client library for Rust. It covers the setup of ProducerClient and ConsumerClient, authentication via Entra ID using DeveloperToolsCredential or ManagedIdentityCredential, and patterns for sending and receiving events. The documentation outlines how to manage event partitions, implement batch sending, and control consumer start positions within a Rust application.
What it does
- Provides methods to send individual events to Azure Event Hubs
- Supports batch event creation and transmission for throughput optimization
- Enables event consumption from specific partitions
- Allows configuration of consumer start positions
- Integrates with Azure identity providers for secure authentication
- Defines patterns for handling event streams and error states
When to use it
- When building Rust applications that require streaming data ingestion
- When you need to send or receive events from Azure Event Hubs
- When implementing partition-based event processing in Rust
- When you need to manage event throughput using batching
Advantages
- Uses official Microsoft-supported Rust crates
- Provides clear patterns for local development and production authentication
- Includes specific guidance on handling event data wrappers and stream processing
- Offers structured approaches to partition management and receiver configuration
Usage examples
- “How do I send a batch of events to Azure Event Hubs in Rust?”
- The agent provides code to initialize a ProducerClient, use create_batch to prepare event data, and call send_batch to transmit the collection.
- “Show me how to consume events from a specific partition in Rust.”
- The agent demonstrates using ConsumerClient to open a receiver on a partition, configuring the start position, and iterating through the event stream.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/microsoft/azure-eventhub-rust/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip azure-eventhub-rust.zip -d .agents/skills
Documentation by Microsoft
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_eventhubscrate 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
DeveloperToolsCredential::new(None)?already returns anArc<DeveloperToolsCredential>, so you can pass or clone it directly into.open(). Addazure_coreonly when you need directazure_coreimports such asErrorKind.
Environment Variables
EVENTHUBS_HOST=<namespace>.servicebus.windows.net # Required — fully qualified namespace
EVENTHUB_NAME=<eventhub-name> # Required — name of the Event HubKey Concepts
| Concept | Description |
|---|---|
| Namespace | Container for one or more Event Hubs |
| Event Hub | Stream of events, partitioned for parallel reads |
| Partition | Ordered, append-only sequence of events |
| Producer | Sends events via ProducerClient |
| Consumer | Receives events from partitions via ConsumerClient |
Authentication
Rust Azure SDK code must not use DefaultAzureCredential. The Rust identity crate does not provide that type.
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(())
}Prefer the crate README/examples when checking builder signatures and receive-stream event wrapper shapes.
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>".to_string(),
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 {
// Body is on the inner event data, not the received wrapper: `event.event_data().body()`.
Ok(event) => {
let body = event.event_data().body().unwrap_or_default();
println!("Received: {:?}", body);
}
Err(err) => eprintln!("Error: {:?}", err),
}
}RBAC Roles
For Entra ID auth, assign one of these roles:
| Role | Access |
|---|---|
Azure Event Hubs Data Sender | Send events |
Azure Event Hubs Data Receiver | Receive events |
Azure Event Hubs Data Owner | Full access |
Best Practices
Use
cargo addto manage dependencies, never editCargo.tomldirectly. Add and remove Rust SDK dependencies with cargo commands instead of manual manifest edits.Pass or clone credentials directly into
.open().DeveloperToolsCredential::new(None)?already returns anArc, so you do not need to annotate the binding asArc<dyn TokenCredential>unless you are naming that trait object type explicitly.Match the builder signature.
ProducerClient::builder().open(...)takes the hub name as&str, whileConsumerClient::builder().open(...)takes an ownedString.Use
DeveloperToolsCredentialfor local dev,ManagedIdentityCredentialfor production — Rust does not provide a singleDefaultAzureCredentialtypeNever hardcode credentials — use environment variables or managed identity
Use batching —
create_batch+send_batchfor throughput optimizationHandle errors per event — match on
Ok/Errin the event streamExtract event bodies via
event.event_data().body(), notevent.body()—ReceivedEventDatawraps the underlyingEventData.Specify start position — use
StartLocation::EarliestorStartLocation::Latestto control where consumption beginsRun
cargo clippy -- -D warningswhen the prompt, eval, or CI expects lint-clean output
Reference Links
Files
- ATTRIBUTION.mdAdded by AutoGineer964 B
- LICENSELicence file added by AutoGineer1.1 KiB
- SKILL.md6.7 KiB
LICENSE
MIT License
Copyright (c) Microsoft Corporation.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARERequirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- Microsoft
- Publisher
- Microsoft (Official)
- Source
- microsoft/skills · .github/plugins/azure-sdk-rust/skills/azure-eventhub-rust · commit 0696600
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Microsoft or Microsoft.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download azure-eventhub-rust.zip