microsoft/skills

azure-eventhub-dotnet

区分事件入缓冲、实际发送和消费者进度提交

  • SKILL.md 已保存
  • 中文用法已整理
  • 安装与运行未实测
先判断是否解决你的问题

azure-eventhub-dotnet 是什么?

azure-eventhub-dotnet 为C#流式采集选择即时producer、缓冲producer或带Blob检查点的EventProcessorClient。它关注分区内事件顺序、批量大小、处理成功后的进度提交与应用关闭,适合长期运行的事件流水线。

中文说明由本站依据来源整理;英文原文保留在页面下方。

按客户端选择安装入口

怎么接入你的 Agent?

  1. 定位完整 Skill 目录

    打开本项目来源,核对 SKILL.md 及其引用的脚本和资料。

  2. 交给你正在用的 Agent

    在下面选择客户端,展开并复制安装指令,让 Agent 读取来源后选择安装方式。

  3. 确认识别,再做具体任务

    让 Agent 回报安装目录和识别到的名称 azure-eventhub-dotnet,然后按本页使用示例提供材料。

展开并复制给 Codex 的安装指令
发送给 Codex

安装并检查 azure-eventhub-dotnet

请在 Codex 的当前工作环境中安装并检查 azure-eventhub-dotnet 这个 Skill。

项目身份:microsoft/skills / azure-eventhub-dotnet
来源:https://github.com/microsoft/skills/blob/f03ec5392f7a0f3aca12af47477e92f1edf7b44c/.github/plugins/azure-sdk-dotnet/skills/azure-eventhub-dotnet/SKILL.md
已定位的源文件:.github/plugins/azure-sdk-dotnet/skills/azure-eventhub-dotnet/SKILL.md

1. 先阅读真实 SKILL.md 和它引用的必要文件,确认触发条件、安装方式、依赖与权限;尊重源文件要求的审批步骤。
2. 按当前客户端支持的方式安装完整 Skill 目录,保留已有配置,不只复制一段提示词。涉及缺失凭证、目标目录或权限时先列出缺项并向我确认。
3. 安装后回读实际目录、Skill 名称和识别结果,说明哪些步骤已完成,哪些只是文档检查,不得把安装成功当作任务已经实测。
4. 如来源提供了可安全验证的示例,在我提供所需输入后做一个最小任务;创建、修改、删除、部署或发送内容前,按源文件和我的授权执行。
准备输入,再按步骤执行

装好以后,具体怎么用?

准备哪些材料

  • 安装EventHubs、Identity;需要processor时加Processor与Blob依赖,准备namespace、hub、consumer group和checkpoint容器,并分别核对Hub与Blob权限。

会得到什么

  • C#批量/缓冲发送或processor接入方案、检查点策略和关闭处理。

实际使用顺序

  1. 即时发送用CreateBatchAsync并检查TryAdd;批满先发送旧批再创建新批,单事件放不进空批则单独报告过大。源中using声明后重新赋值batch的片段需要调整资源管理,不能原样编译。
  2. BufferedProducer注册成功/失败回调,退出前Flush;Enqueue成功仅表示进入缓冲,不等于远端已收。Producer与batch在合适生命周期释放。
  3. 长期消费用EventProcessorClient接BlobCheckpointStore,业务完成后按分区与策略UpdateCheckpoint,注册ProcessError并在取消时finally StopProcessing;用全局计数跨分区每100条checkpoint不能当每分区进度保证。
使用示例

从一个具体任务开始

本站根据源文件编写的使用示例,未在本站实际运行。示例中的文件由你提供。

安装并识别 Skill 后发送

复制一个具体任务

教学任务:使用 azure-eventhub-dotnet,为C#遥测消费者设计EventProcessorClient与Blob检查点。业务成功才提交各分区进度,取消时可靠StopProcessing,说明重启可能重放以及如何按事件id去重;只给代码,不连接Hub或创建Blob容器。
预期结果

预期得到处理、checkpoint和关闭阶段明确的设计;本站未执行事件流水线。

使用前先看这些限制

使用条件与边界

  • checkpoint记录恢复位置,不保证外部业务副作用恰好一次;失败重放与业务幂等需独立设计。
  • 源文件推荐processor作为长期消费者,不能把示例日志打印当真正业务处理完成。
针对这个 Skill 的疑问

常见问题

EnqueueEventAsync完成就算发送成功吗?

缓冲producer还会后台发送,应观察成功/失败回调并在关闭前Flush。入队与服务端实际接收需要分别记录。

需要核对时再展开原文

来源原文与资料状态

源文件
已保存 SKILL.md,抓取于 2026-11-16T12:36:35.145Z
中文使用说明
已针对下方源文件版本整理用途、用法和常见问题
安装与任务测试
本站未执行安装或任务测试
来源复核
本页中文用法已对照保存版本的完整 SKILL.md 阅读整理
展开 SKILL.md 原文、章节与历史收录资料

.github/plugins/azure-sdk-dotnet/skills/azure-eventhub-dotnet/SKILL.md · 抓取时间 2026-11-16T12:36:35.145Z

以下保留源文件的 description、章节及摘录,供核对中文说明;完整文件通过上方链接打开。

抓取成功不代表已完成安装或任务测试。

来源 description(原文)

Azure Event Hubs SDK for .NET. Use for high-throughput event streaming: sending events (EventHubProducerClient, EventHubBufferedProducerClient), receiving events (EventProcessorClient with checkpointing), partition management, and real-time data ingestion. Triggers: "Event Hubs", "event streaming", "EventHubProducerClient", "EventProcessorClient", "send events", "receive events", "checkpointing", "partition".

查看源文件章节 / Source sections
  • 原文:Azure.Messaging.EventHubs (.NET)
  • 安装 / Installation
  • 原文:Environment Variables
  • 原文:Authentication
  • 原文:Client Types
  • 原文:Core Workflow
  • 原文:1. Send Events (Batch)
  • 原文:2. Send Events (Buffered - High Volume)
  • 原文:3. Receive Events (Production - EventProcessorClient)
  • 原文:4. Partition Operations
  • 原文:EventPosition Options
  • 原文:ASP.NET Core Integration
  • 原文:Best Practices
  • 原文:Error Handling
  • 原文:Checkpointing Strategies
  • 原文:Related SDKs
原文:Azure.Messaging.EventHubs (.NET)

High-throughput event streaming SDK for sending and receiving events via Azure Event Hubs.

安装 / Installation

```bash # Core package (sending and simple receiving) dotnet add package Azure.Messaging.EventHubs # Processor package (production receiving with checkpointing) dotnet add package Azure.Messaging.EventHubs.Processor # Authentication dotnet add package Azure.Identity # For checkpointing (required by EventProcessorClient) dotnet add package Azure.Storage.Blobs ``` **Current Versions**: Azure.Messaging.EventHubs v5.12.2, Azure.Messaging.EventHubs.Processor v5.12.2

原文:Environment Variables

```bash EVENTHUB_FULLY_QUALIFIED_NAMESPACE=<namespace>.servicebus.windows.net # Required: Event Hubs fully qualified namespace EVENTHUB_NAME=<event-hub-name> # Required: Event Hub name BLOB_STORAGE_CONNECTION_STRING=<storage-connection-string> # Alternative to Entra ID auth BLOB_CONTAINER_NAME=<checkpoint-container> # Required: checkpoint container name EVENTHUB_CONNECTION_STRING=Endpoint=sb://<namespace>.servicebus.windows.net/;SharedAccessKeyName=... # Alternative to Entra ID auth AZURE_TOKEN_CREDENTIALS=prod # Required only if DefaultAzureCredential is used in production ```

原文:Authentication

```csharp using Azure.Identity; using Azure.Messaging.EventHubs; using Azure.Messaging.EventHubs.Producer; // Local dev: DefaultAzureCredential. Production: set AZURE_TOKEN_CREDENTIALS=prod or AZURE_TOKEN_CREDENTIALS=<specific_credential> var credential = new DefaultAzureCredential( DefaultAzureCredential.DefaultEnvironmentVariableName ); // Or use a specific credential directly in production: // See https://learn.microsoft.com/dotnet/api/overview/azure/identity-readme?view=azure-dotnet#credential-classes // var credential = new ManagedIdentityCredential(); var fullyQualifiedNamespace = Environment.GetEnvironmentVariable("EVENTHUB_FULLY_QUALIFIED_NAMESPACE"); var eventHubName = Environment.GetEnvironmentVariable("EVENTHUB_NAME"); var producer = new EventHubProducerClient( fullyQualifiedNamespace, eventHubName, credential); ``` **Required RBAC Roles**: - **Sending**: `Azure Event Hubs Data Sender` - **Receiving**: `Azure Event Hubs Data Receiver` - **Both**: `Azure Event Hubs Data Owner`

原文:Client Types

| Client | Purpose | When to Use | |--------|---------|-------------| | `EventHubProducerClient` | Send events immediately in batches | Real-time sending, full control over batching | | `EventHubBufferedProducerClient` | Automatic batching with background sending | High-volume, fire-and-forget scenarios | | `EventHubConsumerClient` | Simple event reading | Prototyping only, NOT for production | | `EventProcessorClient` | Production event processing | **Always use this for receiving in production** |

原文:1. Send Events (Batch)

```csharp using Azure.Identity; using Azure.Messaging.EventHubs; using Azure.Messaging.EventHubs.Producer; await using var producer = new EventHubProducerClient( fullyQualifiedNamespace, eventHubName, new DefaultAzureCredential()); // Create a batch (respects size limits automatically) using EventDataBatch batch = await producer.CreateBatchAsync(); // Add events to batch var events = new[] { new EventData(BinaryData.FromString("{\"id\": 1, \"message\": \"Hello\"}")), new EventData(BinaryData.FromString("{\"id\": 2, \"message\": \"World\"}")) }; foreach (var eventData in events) { if (!batch.TryAdd(eventData)) { // Batch is full - send it and create a new one await producer.SendAsync(batch); batch = await producer.CreateBatchAsync(); if (!batch.TryAdd(eventData)) { throw new Exception("Event too large for empty batch"); } } } // Send remaining events if (batch.Count > 0) { await producer.SendAsync(batch); } ```

文件 SHA256:f9b30ce076b96ee944e8863b553d48851a6ffaf6ab0e94acff72745b41ccf686

仓库许可证记录:MIT;skill-declaration-captured-not-interpreted,查看来源。

SKILL.md原文description · 2026-11-16T12:36:35.145Z

Azure Event Hubs SDK for .NET. Use for high-throughput event streaming: sending events (EventHubProducerClient, EventHubBufferedProducerClient), receiving events (EventProcessorClient with checkpointing), partition management, and real-time data ingestion. Triggers: "Event Hubs", "event streaming", "EventHubProducerClient", "EventProcessorClient", "send events", "receive events", "checkpointing", "partition".

查看历史简介来源

历史收录数据

来源仓库microsoft/skills
Skill源路径.github/plugins/azure-sdk-dotnet/skills/azure-eventhub-dotnet/SKILL.md

安装前请让使用的Agent先读取这个SKILL.md及其所在目录,确认依赖和所需权限。此页不生成未经来源验证的安装命令。

返回 Skills 目录,按任务继续筛选 · MCP与Skills教程与资源