azure-eventgrid-py

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

31,392 stars
Complexity: medium

About this skill

This skill empowers AI agents to leverage Azure Event Grid, a fully managed event routing service, for building sophisticated event-driven architectures. By integrating the Azure Event Grid SDK for Python, agents can publish custom events, process standard CloudEvents, and subscribe to various Azure services or custom topics. It enables AI agents to participate in and orchestrate complex workflows, respond to real-time changes, and create decoupled, scalable applications using pub/sub semantics. The skill provides the necessary Python libraries for authentication and interaction with Event Grid topics and namespaces, allowing agents to act as producers or consumers within an event-driven ecosystem.

Best use case

Publishing custom events triggered by an AI agent's actions, decisions, or detected patterns to other systems or services. Integrating an AI agent into an existing event-driven microservices architecture within Azure. Notifying other services, applications, or users about specific events generated by the AI agent (e.g., 'anomaly detected', 'task completed', 'user intent identified'). Building event-driven automation workflows where the AI agent triggers or responds to events in Azure. Creating serverless applications where the AI agent's logic is activated by or activates Event Grid events for scalable processing.

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

Successful publication of an event to a specified Azure Event Grid topic or namespace. An AI agent capable of generating event payloads conforming to CloudEvents or custom schemas and sending them to a configured Event Grid endpoint. An AI agent effectively integrated into an event-driven workflow, either as a reliable publisher or a potential consumer of events. Real-time updates or actions triggered in other systems or services based on the agent's activities or generated events.

Practical example

Example input

Publish a critical alert event to the 'security-alerts' topic with a subject '/systems/main_server' and data indicating 'High CPU utilization detected on main server, exceeding 90% for 5 minutes'.

Example output

{
  "status": "success",
  "message": "Critical alert event successfully published to Azure Event Grid topic 'security-alerts'.",
  "event_details": {
    "topic_name": "security-alerts",
    "event_id": "{{GENERATED_EVENT_ID}}",
    "subject": "/systems/main_server",
    "event_type": "Security.Alert.Critical",
    "data": {
      "alert_type": "CPU_Utilization",
      "threshold_exceeded": "90%",
      "duration_minutes": 5,
      "server_name": "main_server"
    }
  }
}

When to use this skill

  • When the AI agent needs to participate in an event-driven system or communicate asynchronously with other components via events.
  • When there's a requirement to publish real-time notifications, data streams, or state changes from the agent's operations.
  • When the AI agent needs to consume events from other Azure services or custom sources for decision-making or task execution.
  • When building scalable and decoupled applications where the agent's actions trigger downstream processes without direct coupling.

When not to use this skill

  • For simple, direct API calls or synchronous request-response interactions that do not require event routing or pub/sub patterns.
  • When working with real-time streaming data that requires high-throughput, extremely low-latency processing and direct access to stream processors (e.g., Azure Stream Analytics, Apache Kafka).
  • If the target system is not in Azure or does not utilize Azure Event Grid for event communication.
  • For tasks primarily involving long-running computations or complex database transactions that are better suited for dedicated workflow orchestration services.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/azure-eventgrid-py/SKILL.md --create-dirs "https://raw.githubusercontent.com/sickn33/antigravity-awesome-skills/main/plugins/antigravity-awesome-skills-claude/skills/azure-eventgrid-py/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/azure-eventgrid-py/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How azure-eventgrid-py Compares

Feature / Agentazure-eventgrid-pyStandard Approach
Platform SupportClaudeLimited / Varies
Context Awareness High Baseline
Installation ComplexitymediumN/A

Frequently Asked Questions

What does this skill do?

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

Which AI agents support this skill?

This skill is designed for Claude.

How difficult is it to install?

The installation complexity is rated as medium. You can find the installation instructions above.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# Azure Event Grid SDK for Python

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

## Installation

```bash
pip install azure-eventgrid azure-identity
```

## Environment Variables

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

## Authentication

```python
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

```python
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

```python
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

```python
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

```python
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

```python
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):

```python
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.

Related Skills

azure-storage-queue-ts

31392
from sickn33/antigravity-awesome-skills

Azure Queue Storage JavaScript/TypeScript SDK (@azure/storage-queue) for message queue operations. Use for sending, receiving, peeking, and deleting messages in queues.

Cloud IntegrationClaude

azure-storage-queue-py

31392
from sickn33/antigravity-awesome-skills

Azure Queue Storage SDK for Python. Use for reliable message queuing, task distribution, and asynchronous processing.

Cloud IntegrationClaude

azure-servicebus-dotnet

31392
from sickn33/antigravity-awesome-skills

Azure Service Bus SDK for .NET. Enterprise messaging with queues, topics, subscriptions, and sessions.

Cloud IntegrationClaudeChatGPTGemini

azure-monitor-ingestion-java

31392
from sickn33/antigravity-awesome-skills

Azure Monitor Ingestion SDK for Java. Send custom logs to Azure Monitor via Data Collection Rules (DCR) and Data Collection Endpoints (DCE).

Cloud IntegrationClaude

azure-identity-py

31392
from sickn33/antigravity-awesome-skills

Azure Identity SDK for Python authentication. Use for DefaultAzureCredential, managed identity, service principals, and token caching.

Cloud IntegrationClaude

azure-eventgrid-java

31392
from sickn33/antigravity-awesome-skills

Build event-driven applications with Azure Event Grid SDK for Java. Use when publishing events, implementing pub/sub patterns, or integrating with Azure services via events.

Cloud IntegrationClaudeChatGPTGemini

azure-eventgrid-dotnet

31392
from sickn33/antigravity-awesome-skills

Azure Event Grid SDK for .NET. Client library for publishing and consuming events with Azure Event Grid. Use for event-driven architectures, pub/sub messaging, CloudEvents, and EventGridEvents.

Cloud IntegrationClaude

microsoft-azure-webjobs-extensions-authentication-events-dotnet

31392
from sickn33/antigravity-awesome-skills

Microsoft Entra Authentication Events SDK for .NET. Azure Functions triggers for custom authentication extensions.

Identity Management / Authentication & AuthorizationClaude

azure-web-pubsub-ts

31392
from sickn33/antigravity-awesome-skills

Real-time messaging with WebSocket connections and pub/sub patterns.

Messaging & CommunicationClaude

azure-storage-file-share-ts

31392
from sickn33/antigravity-awesome-skills

Azure File Share JavaScript/TypeScript SDK (@azure/storage-file-share) for SMB file share operations.

Cloud Storage ManagementClaude

azure-storage-file-share-py

31392
from sickn33/antigravity-awesome-skills

Azure Storage File Share SDK for Python. Use for SMB file shares, directories, and file operations in the cloud.

Cloud Storage ManagementClaude

azure-storage-file-datalake-py

31392
from sickn33/antigravity-awesome-skills

Azure Data Lake Storage Gen2 SDK for Python. Use for hierarchical file systems, big data analytics, and file/directory operations.

Cloud Storage ManagementClaude