[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-53108a21-b675-4cf7-a9a4-c29a2af52560":3,"$fbUB3nX-5q1qNJ1weqfNlfATDjnMI2xifwgnhm1xJgk0":43},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":34},"53108a21-b675-4cf7-a9a4-c29a2af52560","azure-eventgrid-py","Azure事件网格Python SDK。用于发布事件、处理CloudEvents和事件驱动架构。","cat_coding_devops","mod_coding","sickn33,coding","---\nname: azure-eventgrid-py\ndescription: Azure Event Grid SDK for Python. Use for publishing events, handling CloudEvents, and event-driven architectures.\nrisk: unknown\nsource: community\ndate_added: '2026-02-27'\n---\n\n# Azure Event Grid SDK for Python\n\nEvent routing service for building event-driven applications with pub\u002Fsub semantics.\n\n## Installation\n\n```bash\npip install azure-eventgrid azure-identity\n```\n\n## Environment Variables\n\n```bash\nEVENTGRID_TOPIC_ENDPOINT=https:\u002F\u002F\u003Ctopic-name>.\u003Cregion>.eventgrid.azure.net\u002Fapi\u002Fevents\nEVENTGRID_NAMESPACE_ENDPOINT=https:\u002F\u002F\u003Cnamespace>.\u003Cregion>.eventgrid.azure.net\n```\n\n## Authentication\n\n```python\nfrom azure.identity import DefaultAzureCredential\nfrom azure.eventgrid import EventGridPublisherClient\n\ncredential = DefaultAzureCredential()\nendpoint = \"https:\u002F\u002F\u003Ctopic-name>.\u003Cregion>.eventgrid.azure.net\u002Fapi\u002Fevents\"\n\nclient = EventGridPublisherClient(endpoint, credential)\n```\n\n## Event Types\n\n| Format | Class | Use Case |\n|--------|-------|----------|\n| Cloud Events 1.0 | `CloudEvent` | Standard, interoperable (recommended) |\n| Event Grid Schema | `EventGridEvent` | Azure-native format |\n\n## Publish CloudEvents\n\n```python\nfrom azure.eventgrid import EventGridPublisherClient, CloudEvent\nfrom azure.identity import DefaultAzureCredential\n\nclient = EventGridPublisherClient(endpoint, DefaultAzureCredential())\n\n# Single event\nevent = CloudEvent(\n    type=\"MyApp.Events.OrderCreated\",\n    source=\"\u002Fmyapp\u002Forders\",\n    data={\"order_id\": \"12345\", \"amount\": 99.99}\n)\nclient.send(event)\n\n# Multiple events\nevents = [\n    CloudEvent(\n        type=\"MyApp.Events.OrderCreated\",\n        source=\"\u002Fmyapp\u002Forders\",\n        data={\"order_id\": f\"order-{i}\"}\n    )\n    for i in range(10)\n]\nclient.send(events)\n```\n\n## Publish EventGridEvents\n\n```python\nfrom azure.eventgrid import EventGridEvent\nfrom datetime import datetime, timezone\n\nevent = EventGridEvent(\n    subject=\"\u002Fmyapp\u002Forders\u002F12345\",\n    event_type=\"MyApp.Events.OrderCreated\",\n    data={\"order_id\": \"12345\", \"amount\": 99.99},\n    data_version=\"1.0\"\n)\n\nclient.send(event)\n```\n\n## Event Properties\n\n### CloudEvent Properties\n\n```python\nevent = CloudEvent(\n    type=\"MyApp.Events.ItemCreated\",      # Required: event type\n    source=\"\u002Fmyapp\u002Fitems\",                 # Required: event source\n    data={\"key\": \"value\"},                 # Event payload\n    subject=\"items\u002F123\",                   # Optional: subject\u002Fpath\n    datacontenttype=\"application\u002Fjson\",   # Optional: content type\n    dataschema=\"https:\u002F\u002Fschema.example\",  # Optional: schema URL\n    time=datetime.now(timezone.utc),      # Optional: timestamp\n    extensions={\"custom\": \"value\"}         # Optional: custom attributes\n)\n```\n\n### EventGridEvent Properties\n\n```python\nevent = EventGridEvent(\n    subject=\"\u002Fmyapp\u002Fitems\u002F123\",            # Required: subject\n    event_type=\"MyApp.ItemCreated\",        # Required: event type\n    data={\"key\": \"value\"},                 # Required: event payload\n    data_version=\"1.0\",                    # Required: schema version\n    topic=\"\u002Fsubscriptions\u002F...\u002Ftopics\u002F...\", # Optional: auto-set\n    event_time=datetime.now(timezone.utc)  # Optional: timestamp\n)\n```\n\n## Async Client\n\n```python\nfrom azure.eventgrid.aio import EventGridPublisherClient\nfrom azure.identity.aio import DefaultAzureCredential\n\nasync def publish_events():\n    credential = DefaultAzureCredential()\n    \n    async with EventGridPublisherClient(endpoint, credential) as client:\n        event = CloudEvent(\n            type=\"MyApp.Events.Test\",\n            source=\"\u002Fmyapp\",\n            data={\"message\": \"hello\"}\n        )\n        await client.send(event)\n\nimport asyncio\nasyncio.run(publish_events())\n```\n\n## Namespace Topics (Event Grid Namespaces)\n\nFor Event Grid Namespaces (pull delivery):\n\n```python\nfrom azure.eventgrid.aio import EventGridPublisherClient\n\n# Namespace endpoint (different from custom topic)\nnamespace_endpoint = \"https:\u002F\u002F\u003Cnamespace>.\u003Cregion>.eventgrid.azure.net\"\ntopic_name = \"my-topic\"\n\nasync with EventGridPublisherClient(\n    endpoint=namespace_endpoint,\n    credential=DefaultAzureCredential()\n) as client:\n    await client.send(\n        event,\n        namespace_topic=topic_name\n    )\n```\n\n## Best Practices\n\n1. **Use CloudEvents** for new applications (industry standard)\n2. **Batch events** when publishing multiple events\n3. **Include meaningful subjects** for filtering\n4. **Use async client** for high-throughput scenarios\n5. **Handle retries** — Event Grid has built-in retry\n6. **Set appropriate event types** for routing and filtering\n\n## When to Use\nThis skill is applicable to execute the workflow or actions described in the overview.\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,103,1338,"2026-05-16 13:06:17",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"编程开发","coding","mdi-code-braces","代码生成、调试、审查，提升开发效率",2,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":32,"skillCount":33,"createdAt":26},"DevOps","devops","mdi-cog-outline","CI\u002FCD、容器化、部署运维",3,162,[35],{"id":36,"skillId":4,"version":37,"fileName":38,"fileSize":39,"filePath":40,"fileHash":41,"manifest":42,"createdAt":19},"7a46f53a-fb72-434f-9afd-6975ee86e989","1.0.0","azure-eventgrid-py.zip",1850,"uploads\u002Fskills\u002F53108a21-b675-4cf7-a9a4-c29a2af52560\u002Fazure-eventgrid-py.zip","a90e83b396337cf34a5f9e529946d10bdb8cc52a6a9101b241b7ad3f85f02813","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":4955}]",{"code":44,"message":45,"data":46},200,"success",{"items":47,"stats":48,"page":51},[],{"averageRating":49,"totalRatings":49,"ratingCounts":50},0,[49,49,49,49,49],{"limit":52,"offset":49,"hasMore":53,"nextOffset":52,"ratedOnly":16},15,false]