{
  "schema": "https://ai-atoms.com/schemas/skill-v1.json",
  "type": "skill",
  "id": "skill/azure-eventhub-py",
  "version": "1.0.1",
  "name": "Azure Eventhub Py",
  "description": "Azure Event Hubs SDK for Python streaming. Use for high-throughput event ingestion, producers, consumers, and checkpointing.\nTriggers: \"event hubs\", \"EventHubProducerClient\", \"EventHubConsumerClient\", \"streaming\", \"partitions\".",
  "system_prompt_fragment": "# Azure Event Hubs SDK for Python\n\nBig data streaming platform for high-throughput event ingestion.\n\n## Installation\n\n```bash\npip install azure-eventhub azure-identity\n# For checkpointing with blob storage\npip install azure-eventhub-checkpointstoreblob-aio\n```\n\n## Environment Variables\n\n```bash\nEVENT_HUB_FULLY_QUALIFIED_NAMESPACE=<namespace>.servicebus.windows.net\nEVENT_HUB_NAME=my-eventhub\nSTORAGE_ACCOUNT_URL=https://<account>.blob.core.windows.net\nCHECKPOINT_CONTAINER=checkpoints\n```\n\n## Authentication\n\n```python\nfrom azure.identity import DefaultAzureCredential\nfrom azure.eventhub import EventHubProducerClient, EventHubConsumerClient\n\ncredential = DefaultAzureCredential()\nnamespace = \"<namespace>.servicebus.windows.net\"\neventhub_name = \"my-eventhub\"\n\n# Producer\nproducer = EventHubProducerClient(\n    fully_qualified_namespace=namespace,\n    eventhub_name=eventhub_name,\n    credential=credential\n)\n\n# Consumer\nconsumer = EventHubConsumerClient(\n    fully_qualified_namespace=namespace,\n    eventhub_name=eventhub_name,\n    consumer_group=\"$Default\",\n    credential=credential\n)\n```\n\n## Client Types\n\n| Client | Purpose |\n|--------|---------|\n| `EventHubProducerClient` | Send events to Event Hub |\n| `EventHubConsumerClient` | Receive events from Event Hub |\n| `BlobCheckpointStore` | Track consumer progress |\n\n## Send Events\n\n```python\nfrom azure.eventhub import EventHubProducerClient, EventData\nfrom azure.identity import DefaultAzureCredential\n\nproducer = EventHubProducerClient(\n    fully_qualified_namespace=\"<namespace>.servicebus.windows.net\",\n    eventhub_name=\"my-eventhub\",\n    credential=DefaultAzureCredential()\n)\n\nwith producer:\n    # Create batch (handles size limits)\n    event_data_batch = producer.create_batch()\n    \n    for i in range(10):\n        try:\n            event_data_batch.add(EventData(f\"Event {i}\"))\n        except ValueError:\n            # Batch is full, send and create new one\n            producer.send_batch(event_data_batch)\n            event_data_batch = producer.create_batch()\n            event_data_batch.add(EventData(f\"Event {i}\"))\n    \n    # Send remaining\n    producer.send_batch(event_data_batch)\n```\n\n### Send to Specific Partition\n\n```python\n# By partition ID\nevent_data_batch = producer.create_batch(partition_id=\"0\")\n\n# By partition key (consistent hashing)\nevent_data_batch = producer.create_batch(partition_key=\"user-123\")\n```\n\n## Receive Events\n\n### Simple Receive\n\n```python\nfrom azure.eventhub import EventHubConsumerClient\n\ndef on_event(partition_context, event):\n    print(f\"Partition: {partition_context.partition_id}\")\n    print(f\"Data: {event.body_as_str()}\")\n    partition_context.update_checkpoint(event)\n\nconsumer = EventHubConsumerClient(\n    fully_qualified_namespace=\"<namespace>.servicebus.windows.net\",\n    eventhub_name=\"my-eventhub\",\n    consumer_group=\"$Default\",\n    credential=DefaultAzureCredential()\n)\n\nwith consumer:\n    consumer.receive(\n        on_event=on_event,\n        starting_position=\"-1\",  # Beginning of stream\n    )\n```\n\n### With Blob Checkpoint Store (Production)\n\n```python\nfrom azure.eventhub import EventHubConsumerClient\nfrom azure.eventhub.extensions.checkpointstoreblob import BlobCheckpointStore\nfrom azure.identity import DefaultAzureCredential\n\ncheckpoint_store = BlobCheckpointStore(\n    blob_account_url=\"https://<account>.blob.core.windows.net\",\n    container_name=\"checkpoints\",\n    credential=DefaultAzureCredential()\n)\n\nconsumer = EventHubConsumerClient(\n    fully_qualified_namespace=\"<namespace>.servicebus.windows.net\",\n    eventhub_name=\"my-eventhub\",\n    consumer_group=\"$Default\",\n    credential=DefaultAzureCredential(),\n    checkpoint_store=checkpoint_store\n)\n\ndef on_event(partition_context, event):\n    print(f\"Received: {event.body_as_str()}\")\n    # Checkpoint after processing\n    partition_context.update_checkpoint(event)\n\nwith consumer:\n    consumer.receive(on_event=on_event)\n```\n\n## Async Client\n\n```python\nfrom azure.eventhub.aio import EventHubProducerClient, EventHubConsumerClient\nfrom azure.identity.aio import DefaultAzureCredential\nimport asyncio\n\nasync def send_events():\n    credential = DefaultAzureCredential()\n    \n    async with EventHubProducerClient(\n        fully_qualified_namespace=\"<namespace>.servicebus.windows.net\",\n        eventhub_name=\"my-eventhub\",\n        credential=credential\n    ) as producer:\n        batch = await producer.create_batch()\n        batch.add(EventData(\"Async event\"))\n        await producer.send_batch(batch)\n\nasync def receive_events():\n    async def on_event(partition_context, event):\n        print(event.body_as_str())\n        await partition_context.update_checkpoint(event)\n    \n    async with EventHubConsumerClient(\n        fully_qualified_namespace=\"<namespace>.servicebus.windows.net\",\n        eventhub_name=\"my-eventhub\",\n        consumer_group=\"$Default\",\n        credential=DefaultAzureCredential()\n    ) as consumer:\n        await consumer.receive(on_event=on_event)\n\nasyncio.run(send_events())\n```\n\n## Event Properties\n\n```python\nevent = EventData(\"My event body\")\n\n# Set properties\nevent.properties = {\"custom_property\": \"value\"}\nevent.content_type = \"application/json\"\n\n# Read properties (on receive)\nprint(event.body_as_str())\nprint(event.sequence_number)\nprint(event.offset)\nprint(event.enqueued_time)\nprint(event.partition_key)\n```\n\n## Get Event Hub Info\n\n```python\nwith producer:\n    info = producer.get_eventhub_properties()\n    print(f\"Name: {info['name']}\")\n    print(f\"Partitions: {info['partition_ids']}\")\n    \n    for partition_id in info['partition_ids']:\n        partition_info = producer.get_partition_properties(partition_id)\n        print(f\"Partition {partition_id}: {partition_info['last_enqueued_sequence_number']}\")\n```\n\n## Best Practices\n\n1. **Use batches** for sending multiple events\n2. **Use checkpoint store** in production for reliable processing\n3. **Use async client** for high-throughput scenarios\n4. **Use partition keys** for ordered delivery within a partition\n5. **Handle batch size limits** — catch ValueError when batch is full\n6. **Use context managers** (`with`/`async with`) for proper cleanup\n7. **Set appropriate consumer groups** for different applications\n\n## Reference Files\n\n| File | Contents |\n|------|----------|\n| references/checkpointing.md | Checkpoint store patterns, blob checkpointing, checkpoint strategies |\n| references/partitions.md | Partition management, load balancing, starting positions |\n| scripts/setup_consumer.py | CLI for Event Hub info, consumer setup, and event sending/receiving |\n\n## When to Use\nThis skill is applicable to execute the workflow or actions described in the overview.",
  "applicable_domains": [
    "devops"
  ],
  "category": "devops",
  "invocation": [
    "/azure-eventhub-py"
  ],
  "authored_by": "claudeskills.in community",
  "source_url": "https://claudeskills.in/skill/azure-eventhub-py",
  "provenance": {
    "source": "claudeskills.in",
    "source_url": "https://claudeskills.in/skill/azure-eventhub-py",
    "license": "unknown",
    "imported_at": "2026-09-03",
    "notes": "Aggregated by claudeskills.in from community GitHub lists."
  },
  "tags": [
    "claudeskills",
    "devops"
  ],
  "lifecycle": "draft"
}