Pular para o conteúdo
Skillpedia
APIs e servidores (backend)48 mil · #2315

azure-eventhub-py

Permite que seu agente processe grandes volumes de eventos em tempo real usando o Azure Event Hubs em Python. É útil para coletar e gerenciar fluxos de dados contínuos.

O que ela faz

Este código ajuda a enviar e receber grandes volumes de dados em tempo real, como leituras de sensores ou logs de aplicativos. Ele permite que programas enviem informações para um serviço centralizado (Event Hub) e outros programas leiam essas informações.

Quando usar

  • ✓Enviar dados de muitos sensores para um local central.
  • ✓Coletar logs de vários servidores para análise.
  • ✓Processar mensagens de um aplicativo em tempo real.

Exemplo do que pedir para a IA

“Envie 1000 leituras de temperatura por segundo para o Event Hub 'sensores' no namespace 'meu-namespace'.”

Quer saber mais? Abra as seções abaixo.

Como usar

O jeito mais fácil: copie a mensagem abaixo e cole no Claude, ChatGPT, Cursor ou outra IA. Ela lê a skill e segue as instruções.

Link da skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/azure-eventhub-py/SKILL.md

Mensagem pronta para colar

Use esta skill para me ajudar: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/azure-eventhub-py/SKILL.md Leia o arquivo SKILL.md desse link e siga as instruções dele na minha tarefa.
Como funciona

O código usa bibliotecas específicas do Azure para se conectar ao Event Hub. Ele pode enviar dados em lotes ou receber dados, rastreando o progresso para não perder nenhuma informação.

Instalação

Jeito mais fácil: copie o link da skill e cole no Claude, ChatGPT ou Cursor pedindo para seguir as instruções.

No terminal (Claude Code, Codex, Cursor), na pasta do projeto:

npx skills add sickn33/agentic-awesome-skills --skill azure-eventhub-py

Ou baixe só o arquivo:

curl -L https://raw.githubusercontent.com/sickn33/agentic-awesome-skills/main/plugins/agentic-awesome-skills-claude/skills/azure-eventhub-py/SKILL.md -o SKILL.md
Conteúdo técnico (SKILL.md)

Tradução do texto original do autor no GitHub. Os comandos e códigos estão como no original.

Suporte upstream incluído

Arquivos de suporte estão incluídos em caminhos relativos à skill. Veja UPSTREAM-NOTICE.md para suas fontes fixadas, licenças, hashes e alterações de importação.

Segurança de helper restaurada

scripts/setup_consumer.py autentica no Event Hub configurado. send publica dados de eventos; receive imprime corpos e propriedades de eventos e pode escrever ou avançar um checkpoint de Blob. Confirme o namespace exato, hub, carga útil/contagem, posição inicial, tratamento de dados e destino do checkpoint antes do uso em produção.

SDK do Azure Event Hubs para Python

Plataforma de streaming de big data para ingestão de eventos de alta vazão.

Instalação

pip install azure-eventhub azure-identity
# For checkpointing with blob storage
pip install azure-eventhub-checkpointstoreblob-aio

Variáveis de Ambiente

EVENT_HUB_FULLY_QUALIFIED_NAMESPACE=<namespace>.servicebus.windows.net
EVENT_HUB_NAME=my-eventhub
STORAGE_ACCOUNT_URL=https://<account>.blob.core.windows.net
CHECKPOINT_CONTAINER=checkpoints

Autenticação

from azure.identity import DefaultAzureCredential
from azure.eventhub import EventHubProducerClient, EventHubConsumerClient

credential = DefaultAzureCredential()
namespace = "<namespace>.servicebus.windows.net"
eventhub_name = "my-eventhub"

# Producer
producer = EventHubProducerClient(
    fully_qualified_namespace=namespace,
    eventhub_name=eventhub_name,
    credential=credential
)

# Consumer
consumer = EventHubConsumerClient(
    fully_qualified_namespace=namespace,
    eventhub_name=eventhub_name,
    consumer_group="$Default",
    credential=credential
)

Tipos de Cliente

Cliente Propósito
EventHubProducerClient Enviar eventos para o Event Hub
EventHubConsumerClient Receber eventos do Event Hub
BlobCheckpointStore Rastrear o progresso do consumidor

Enviar Eventos

from azure.eventhub import EventHubProducerClient, EventData
from azure.identity import DefaultAzureCredential

producer = EventHubProducerClient(
    fully_qualified_namespace="<namespace>.servicebus.windows.net",
    eventhub_name="my-eventhub",
    credential=DefaultAzureCredential()
)

with producer:
    # Create batch (handles size limits)
    event_data_batch = producer.create_batch()
    
    for i in range(10):
        try:
            event_data_batch.add(EventData(f"Event {i}"))
        except ValueError:
            # Batch is full, send and create new one
            producer.send_batch(event_data_batch)
            event_data_batch = producer.create_batch()
            event_data_batch.add(EventData(f"Event {i}"))
    
    # Send remaining
    producer.send_batch(event_data_batch)

Enviar para Partição Específica

# By partition ID
event_data_batch = producer.create_batch(partition_id="0")

# By partition key (consistent hashing)
event_data_batch = producer.create_batch(partition_key="user-123")

Receber Eventos

Recebimento Simples

from azure.eventhub import EventHubConsumerClient

def on_event(partition_context, event):
    print(f"Partition: {partition_context.partition_id}")
    print(f"Data: {event.body_as_str()}")
    partition_context.update_checkpoint(event)

consumer = EventHubConsumerClient(
    fully_qualified_namespace="<namespace>.servicebus.windows.net",
    eventhub_name="my-eventhub",
    consumer_group="$Default",
    credential=DefaultAzureCredential()
)

with consumer:
    consumer.receive(
        on_event=on_event,
        starting_position="-1",  # Beginning of stream
    )

Com Blob Checkpoint Store (Produção)

from azure.eventhub import EventHubConsumerClient
from azure.eventhub.extensions.checkpointstoreblob import BlobCheckpointStore
from azure.identity import DefaultAzureCredential

checkpoint_store = BlobCheckpointStore(
    blob_account_url="https://<account>.blob.core.windows.net",
    container_name="checkpoints",
    credential=DefaultAzureCredential()
)

consumer = EventHubConsumerClient(
    fully_qualified_namespace="<namespace>.servicebus.windows.net",
    eventhub_name="my-eventhub",
    consumer_group="$Default",
    credential=DefaultAzureCredential(),
    checkpoint_store=checkpoint_store
)

def on_event(partition_context, event):
    print(f"Received: {event.body_as_str()}")
    # Checkpoint after processing
    partition_context.update_checkpoint(event)

with consumer:
    consumer.receive(on_event=on_event)

Cliente Assíncrono


…
Perguntas frequentes

O que é um 'Event Hub'?

É um serviço na nuvem que funciona como um grande 'correio' para dados. Ele recebe muitos dados de diferentes fontes e permite que outros programas os leiam.

O que é 'streaming'?

É o envio e recebimento de dados continuamente, em vez de esperar que todos os dados cheguem antes de começar a processá-los. Pense em assistir a um vídeo online sem baixá-lo inteiro primeiro.

O que é 'checkpointing'?

É como marcar um ponto em um livro para saber onde você parou de ler. No caso de dados, o 'checkpoint' ajuda o programa a saber quais dados já foram processados para que ele possa continuar de onde parou se for interrompido.

Detalhes

Descrição original do autor

Azure Event Hubs SDK for Python streaming. Use for high-throughput event ingestion, producers, consumers, and checkpointing.

repo: sickn33/agentic-awesome-skills

Popularidade

Estrelas no GitHub
48 mil
Posição no ranking
#2315
Licença
MIT
Atualizada em
15/10/2026

Essa skill é útil?

0

Entre para votar.

Comentários

  • …

Mais skills deste repositório

Skills parecidas