{
  "schema": "https://ai-atoms.com/schemas/skill-v1.json",
  "type": "skill",
  "id": "skill/azure-eventhub-ts",
  "version": "1.0.0",
  "name": "Azure Eventhub Ts",
  "description": "Build event streaming applications using Azure Event Hubs SDK for JavaScript (@azure/event-hubs). Use when implementing high-throughput event ingestion, real-time analytics, IoT telemetry, or event...",
  "system_prompt_fragment": "# Azure Event Hubs SDK for TypeScript\n\nHigh-throughput event streaming and real-time data ingestion.\n\n## Installation\n\n```bash\nnpm install @azure/event-hubs @azure/identity\n```\n\nFor checkpointing with consumer groups:\n```bash\nnpm install @azure/eventhubs-checkpointstore-blob @azure/storage-blob\n```\n\n## Environment Variables\n\n```bash\nEVENTHUB_NAMESPACE=<namespace>.servicebus.windows.net\nEVENTHUB_NAME=my-eventhub\nSTORAGE_ACCOUNT_NAME=<storage-account>\nSTORAGE_CONTAINER_NAME=checkpoints\n```\n\n## Authentication\n\n```typescript\nimport { EventHubProducerClient, EventHubConsumerClient } from \"@azure/event-hubs\";\nimport { DefaultAzureCredential } from \"@azure/identity\";\n\nconst fullyQualifiedNamespace = process.env.EVENTHUB_NAMESPACE!;\nconst eventHubName = process.env.EVENTHUB_NAME!;\nconst credential = new DefaultAzureCredential();\n\n// Producer\nconst producer = new EventHubProducerClient(fullyQualifiedNamespace, eventHubName, credential);\n\n// Consumer\nconst consumer = new EventHubConsumerClient(\n  \"$Default\", // Consumer group\n  fullyQualifiedNamespace,\n  eventHubName,\n  credential\n);\n```\n\n## Core Workflow\n\n### Send Events\n\n```typescript\nconst producer = new EventHubProducerClient(namespace, eventHubName, credential);\n\n// Create batch and add events\nconst batch = await producer.createBatch();\nbatch.tryAdd({ body: { temperature: 72.5, deviceId: \"sensor-1\" } });\nbatch.tryAdd({ body: { temperature: 68.2, deviceId: \"sensor-2\" } });\n\nawait producer.sendBatch(batch);\nawait producer.close();\n```\n\n### Send to Specific Partition\n\n```typescript\n// By partition ID\nconst batch = await producer.createBatch({ partitionId: \"0\" });\n\n// By partition key (consistent hashing)\nconst batch = await producer.createBatch({ partitionKey: \"device-123\" });\n```\n\n### Receive Events (Simple)\n\n```typescript\nconst consumer = new EventHubConsumerClient(\"$Default\", namespace, eventHubName, credential);\n\nconst subscription = consumer.subscribe({\n  processEvents: async (events, context) => {\n    for (const event of events) {\n      console.log(`Partition: ${context.partitionId}, Body: ${JSON.stringify(event.body)}`);\n    }\n  },\n  processError: async (err, context) => {\n    console.error(`Error on partition ${context.partitionId}: ${err.message}`);\n  },\n});\n\n// Stop after some time\nsetTimeout(async () => {\n  await subscription.close();\n  await consumer.close();\n}, 60000);\n```\n\n### Receive with Checkpointing (Production)\n\n```typescript\nimport { EventHubConsumerClient } from \"@azure/event-hubs\";\nimport { ContainerClient } from \"@azure/storage-blob\";\nimport { BlobCheckpointStore } from \"@azure/eventhubs-checkpointstore-blob\";\n\nconst containerClient = new ContainerClient(\n  `https://${storageAccount}.blob.core.windows.net/${containerName}`,\n  credential\n);\n\nconst checkpointStore = new BlobCheckpointStore(containerClient);\n\nconst consumer = new EventHubConsumerClient(\n  \"$Default\",\n  namespace,\n  eventHubName,\n  credential,\n  checkpointStore\n);\n\nconst subscription = consumer.subscribe({\n  processEvents: async (events, context) => {\n    for (const event of events) {\n      console.log(`Processing: ${JSON.stringify(event.body)}`);\n    }\n    // Checkpoint after processing batch\n    if (events.length > 0) {\n      await context.updateCheckpoint(events[events.length - 1]);\n    }\n  },\n  processError: async (err, context) => {\n    console.error(`Error: ${err.message}`);\n  },\n});\n```\n\n### Receive from Specific Position\n\n```typescript\nconst subscription = consumer.subscribe({\n  processEvents: async (events, context) => { /* ... */ },\n  processError: async (err, context) => { /* ... */ },\n}, {\n  startPosition: {\n    // Start from beginning\n    \"0\": { offset: \"@earliest\" },\n    // Start from end (new events only)\n    \"1\": { offset: \"@latest\" },\n    // Start from specific offset\n    \"2\": { offset: \"12345\" },\n    // Start from specific time\n    \"3\": { enqueuedOn: new Date(\"2024-01-01\") },\n  },\n});\n```\n\n## Event Hub Properties\n\n```typescript\n// Get hub info\nconst hubProperties = await producer.getEventHubProperties();\nconsole.log(`Partitions: ${hubProperties.partitionIds}`);\n\n// Get partition info\nconst partitionProperties = await producer.getPartitionProperties(\"0\");\nconsole.log(`Last sequence: ${partitionProperties.lastEnqueuedSequenceNumber}`);\n```\n\n## Batch Processing Options\n\n```typescript\nconst subscription = consumer.subscribe(\n  {\n    processEvents: async (events, context) => { /* ... */ },\n    processError: async (err, context) => { /* ... */ },\n  },\n  {\n    maxBatchSize: 100,           // Max events per batch\n    maxWaitTimeInSeconds: 30,    // Max wait for batch\n  }\n);\n```\n\n## Key Types\n\n```typescript\nimport {\n  EventHubProducerClient,\n  EventHubConsumerClient,\n  EventData,\n  ReceivedEventData,\n  PartitionContext,\n  Subscription,\n  SubscriptionEventHandlers,\n  CreateBatchOptions,\n  EventPosition,\n} from \"@azure/event-hubs\";\n\nimport { BlobCheckpointStore } from \"@azure/eventhubs-checkpointstore-blob\";\n```\n\n## Event Properties\n\n```typescript\n// Send with properties\nconst batch = await producer.createBatch();\nbatch.tryAdd({\n  body: { data: \"payload\" },\n  properties: {\n    eventType: \"telemetry\",\n    deviceId: \"sensor-1\",\n  },\n  contentType: \"application/json\",\n  correlationId: \"request-123\",\n});\n\n// Access in receiver\nconsumer.subscribe({\n  processEvents: async (events, context) => {\n    for (const event of events) {\n      console.log(`Type: ${event.properties?.eventType}`);\n      console.log(`Sequence: ${event.sequenceNumber}`);\n      console.log(`Enqueued: ${event.enqueuedTimeUtc}`);\n      console.log(`Offset: ${event.offset}`);\n    }\n  },\n});\n```\n\n## Error Handling\n\n```typescript\nconsumer.subscribe({\n  processEvents: async (events, context) => {\n    try {\n      for (const event of events) {\n        await processEvent(event);\n      }\n      await context.updateCheckpoint(events[events.length - 1]);\n    } catch (error) {\n      // Don't checkpoint on error - events will be reprocessed\n      console.error(\"Processing failed:\", error);\n    }\n  },\n  processError: async (err, context) => {\n    if (err.name === \"MessagingError\") {\n      // Transient error - SDK will retry\n      console.warn(\"Transient error:\", err.message);\n    } else {\n      // Fatal error\n      console.error(\"Fatal error:\", err);\n    }\n  },\n});\n```\n\n## Best Practices\n\n1. **Use checkpointing** - Always checkpoint in production for exactly-once processing\n2. **Batch sends** - Use `createBatch()` for efficient sending\n3. **Partition keys** - Use partition keys to ensure ordering for related events\n4. **Consumer groups** - Use separate consumer groups for different processing pipelines\n5. **Handle errors gracefully** - Don't checkpoint on processing failures\n6. **Close clients** - Always close producer/consumer when done\n7. **Monitor lag** - Track `lastEnqueuedSequenceNumber` vs processed sequence\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-ts"
  ],
  "authored_by": "claudeskills.in community",
  "source_url": "https://claudeskills.in/skill/azure-eventhub-ts",
  "provenance": {
    "source": "claudeskills.in",
    "source_url": "https://claudeskills.in/skill/azure-eventhub-ts",
    "license": "unknown",
    "imported_at": "2026-09-03",
    "notes": "Aggregated by claudeskills.in from community GitHub lists."
  },
  "tags": [
    "claudeskills",
    "devops"
  ],
  "lifecycle": "draft"
}