본문으로 건너뛰기
Skillpedia
API 및 서버 (백엔드)48k · #3926

azure-eventgrid-py

하는 일

프로그램이 Azure Event Grid에 메시지(이벤트)를 보내도록 해 주는 코드입니다. 새 주문이 들어왔을 때처럼 프로그램의 여러 부분이 이벤트를 통해 소통하는 시스템을 만드는 데 쓰입니다.

사용하는 경우

  • ✓프로그램에서 일어난 일을 다른 시스템에 알려야 할 때.
  • ✓실시간 이벤트에 반응하는 애플리케이션을 만들 때.
  • ✓서로 소통해야 하는 여러 클라우드 서비스를 연결할 때.

스킬 링크

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

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/azure-eventgrid-py/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“ID 12345, 금액 99.99를 담은 ‘order created’ 이벤트를 보내 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

특별한 주소(엔드포인트)와 접근 자격 증명으로 프로그램을 설정합니다. 그다음 무슨 일이 일어났는지 정보를 담은 메시지(이벤트)를 만들고 코드로 보냅니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Azure Event Grid SDK for Python

Event routing service for building event-driven applications with pub/sub semantics.

Installation

pip install azure-eventgrid azure-identity

Environment Variables

EVENTGRID_TOPIC_ENDPOINT=https://<topic-name>.<region>.eventgrid.azure.net/api/events
EVENTGRID_NAMESPACE_ENDPOINT=https://<namespace>.<region>.eventgrid.azure.net

Authentication

from azure.identity import DefaultAzureCredential
from azure.eventgrid import EventGridPublisherClient

credential = DefaultAzureCredential()
endpoint = "https://<topic-name>.<region>.eventgrid.azure.net/api/events"

client = EventGridPublisherClient(endpoint, credential)

Event Types

Format Class Use Case
Cloud Events 1.0 CloudEvent Standard, interoperable (recommended)
Event Grid Schema EventGridEvent Azure-native format

Publish CloudEvents

from azure.eventgrid import EventGridPublisherClient, CloudEvent
from azure.identity import DefaultAzureCredential

client = EventGridPublisherClient(endpoint, DefaultAzureCredential())

# Single event
event = CloudEvent(
    type="MyApp.Events.OrderCreated",
    source="/myapp/orders",
    data={"order_id": "12345", "amount": 99.99}
)
client.send(event)

# Multiple events
events = [
    CloudEvent(
        type="MyApp.Events.OrderCreated",
        source="/myapp/orders",
        data={"order_id": f"order-{i}"}
    )
    for i in range(10)
]
client.send(events)

Publish EventGridEvents

from azure.eventgrid import EventGridEvent
from datetime import datetime, timezone

event = EventGridEvent(
    subject="/myapp/orders/12345",
    event_type="MyApp.Events.OrderCreated",
    data={"order_id": "12345", "amount": 99.99},
    data_version="1.0"
)

client.send(event)

Event Properties

CloudEvent Properties

event = CloudEvent(
    type="MyApp.Events.ItemCreated",      # Required: event type
    source="/myapp/items",                 # Required: event source
    data={"key": "value"},                 # Event payload
    subject="items/123",                   # Optional: subject/path
    datacontenttype="application/json",   # Optional: content type
    dataschema="https://schema.example",  # Optional: schema URL
    time=datetime.now(timezone.utc),      # Optional: timestamp
    extensions={"custom": "value"}         # Optional: custom attributes
)

EventGridEvent Properties

event = EventGridEvent(
    subject="/myapp/items/123",            # Required: subject
    event_type="MyApp.ItemCreated",        # Required: event type
    data={"key": "value"},                 # Required: event payload
    data_version="1.0",                    # Required: schema version
    topic="/subscriptions/.../topics/...", # Optional: auto-set
    event_time=datetime.now(timezone.utc)  # Optional: timestamp
)

Async Client

from azure.eventgrid.aio import EventGridPublisherClient
from azure.identity.aio import DefaultAzureCredential

async def publish_events():
    credential = DefaultAzureCredential()
    
    async with EventGridPublisherClient(endpoint, credential) as client:
        event = CloudEvent(
            type="MyApp.Events.Test",
            source="/myapp",
            data={"message": "hello"}
        )
        await client.send(event)

import asyncio
asyncio.run(publish_events())

Namespace Topics (Event Grid Namespaces)

For Event Grid Namespaces (pull delivery):

from azure.eventgrid.aio import EventGridPublisherClient

# Namespace endpoint (different from custom topic)
namespace_endpoint = "https://<namespace>.<region>.eventgrid.azure.net"
topic_name = "my-topic"

async with EventGridPublisherClient(
    endpoint=namespace_endpoint,
    credential=DefaultAzureCredential()
) as client:
    await client.send(
        event,
        namespace_topic=topic_name
    )

Best Practices

  1. Use CloudEvents for new applications (industry standard)
  2. Batch events when publishing multiple events
  3. Include meaningful subjects for filtering
  4. Use async client for high-throughput scenarios
  5. Handle retries — Event Grid has built-in retry
  6. Set appropriate event types for routing and filtering

When to Use

This skill is applicable to execute the workflow or actions described in the overview.

Limitations

…

자주 묻는 질문

‘이벤트’란 무엇인가요?

알림과 같습니다. 새 사용자가 가입했거나 상품이 팔렸다는 등 무언가 일어났음을 알려 줍니다.

‘Azure Event Grid’는 무엇인가요?

시스템의 여러 부분이나 여러 시스템 사이에서 이런 알림(이벤트)을 관리하고 전달하도록 돕는 Microsoft 서비스입니다.

‘CloudEvents’와 ‘EventGridEvent’의 차이는 무엇인가요?

CloudEvents는 서로 다른 시스템이 이해할 수 있도록 권장되는 더 일반적인 표준입니다. EventGridEvent는 Azure 전용 형식입니다.

상세 정보

작성자의 원본 설명

Azure Event Grid SDK for Python. Use for publishing events, handling CloudEvents, and event-driven architectures.

repo: sickn33/agentic-awesome-skills

인기도

GitHub 스타
48k
순위
#3926
라이선스
MIT
업데이트
2026. 10. 15.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬