【研发类-框架和库Skills】azure-eventgrid-py 技能 Azure Event Grid SDK for Python。用于发布事件、处理CloudEvents和构建事件驱动架构。技能概述azure-eventgrid-py 技能提供了Azure Event Grid SDK for Python的完整使用指南。该技能帮助开发者构建事件驱动应用程序支持发布事件到Event Grid主题、使用CloudEvents和EventGridEvents模式、以及实现发布/订阅消息传递。下载地址https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/azure-eventgrid-py主要功能事件发布: 将事件发布到Event Grid主题和命名空间CloudEvents支持: 使用CNCF标准的CloudEvents 1.0模式EventGridEvents支持: 使用Azure原生事件模式命名空间主题: 支持Event Grid命名空间的拉取传递异步客户端: 支持异步操作提高性能触发条件在以下情况下应该调用此技能:需要构建事件驱动架构实现发布/订阅消息传递使用CloudEvents或EventGridEvents需要发布事件到Azure Event Grid实现事件路由和过滤安装方法pip install azure-eventgrid azure-identity环境变量EVENTGRID_TOPIC_ENDPOINThttps://topic-name.region.eventgrid.azure.net/api/events EVENTGRID_NAMESPACE_ENDPOINThttps://namespace.region.eventgrid.azure.net事件类型格式类用例Cloud Events 1.0CloudEvent标准、可互操作推荐Event Grid SchemaEventGridEventAzure原生格式使用示例示例1: 创建客户端from azure.identity import DefaultAzureCredentialfrom azure.eventgrid import EventGridPublisherClientcredential DefaultAzureCredential()endpoint https://topic-name.region.eventgrid.azure.net/api/eventsclient EventGridPublisherClient(endpoint, credential)示例2: 发布CloudEventsfrom azure.eventgrid import EventGridPublisherClient, CloudEventfrom azure.identity import DefaultAzureCredentialclient EventGridPublisherClient(endpoint, DefaultAzureCredential())# 单个事件event CloudEvent(typeMyApp.Events.OrderCreated,source/myapp/orders,data{order_id: 12345, amount: 99.99})client.send(event)# 多个事件events [CloudEvent(typeMyApp.Events.OrderCreated,source/myapp/orders,data{order_id: forder-{i}})for i in range(10)]client.send(events)示例3: 发布EventGridEventsfrom azure.eventgrid import EventGridEventfrom datetime import datetime, timezoneevent EventGridEvent(subject/myapp/orders/12345,event_typeMyApp.Events.OrderCreated,data{order_id: 12345, amount: 99.99},data_version1.0)client.send(event)示例4: CloudEvent属性event CloudEvent(typeMyApp.Events.ItemCreated, # 必需: 事件类型source/myapp/items, # 必需: 事件源data{key: value}, # 事件负载subjectitems/123, # 可选: 主题/路径datacontenttypeapplication/json, # 可选: 内容类型dataschemahttps://schema.example, # 可选: 模式URLtimedatetime.now(timezone.utc), # 可选: 时间戳extensions{custom: value} # 可选: 自定义属性)示例5: 异步客户端from azure.eventgrid.aio import EventGridPublisherClientfrom azure.identity.aio import DefaultAzureCredentialasync def publish_events():credential DefaultAzureCredential()async with EventGridPublisherClient(endpoint, credential) as client:event CloudEvent(typeMyApp.Events.Test,source/myapp,data{message: hello})await client.send(event)import asyncioasyncio.run(publish_events())示例6: 命名空间主题from azure.eventgrid.aio import EventGridPublisherClient# 命名空间端点不同于自定义主题namespace_endpoint https://namespace.region.eventgrid.azure.nettopic_name my-topicasync with EventGridPublisherClient(endpointnamespace_endpoint,credentialDefaultAzureCredential()) as client:await client.send(event,namespace_topictopic_name)最佳实践使用CloudEvents: 新应用程序使用CloudEvents行业标准批量事件: 发布多个事件时使用批量发送包含有意义的主题: 用于过滤和路由使用异步客户端: 用于高吞吐量场景处理重试: Event Grid内置重试机制设置适当的事件类型: 用于路由和过滤限制说明仅当任务明确符合上述范围时使用此技能不要将输出视为环境特定验证、测试或专家审查的替代品如果缺少所需的输入、权限、安全边界或成功标准请停止并寻求澄清

相关新闻

最新新闻

招行信用卡中心IT笔试测试方向全攻略:考点、题型与备考指南

招行信用卡中心IT笔试测试方向全攻略:考点、题型与备考指南

作为一个参加过招商银行信用卡中心2018春招IT笔试(测试方向第一批)的人,我来聊聊那场笔试。说实话,银行系的IT笔试和互联网大厂的风格差别挺大,它不会像LeetCode那样只考算法,也不会像某些外包公司那样随便…

2026/8/31 20:00:48
10分钟跑通Metabot:Metabase用自然语言查数据的完整实战指南

10分钟跑通Metabot:Metabase用自然语言查数据的完整实战指南

10分钟跑通Metabot:Metabase用自然语言查数据的完整实战指南 【免费下载链接】metabase The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart: 项目地址: https://gitcode.com/GitHub_…

2026/8/31 20:00:48
jeecg-boot跨域配置实战:从报错到生效的三档落地清单

jeecg-boot跨域配置实战:从报错到生效的三档落地清单

jeecg-boot跨域配置实战:从报错到生效的三档落地清单 【免费下载链接】jeecg-boot 【低代码v2.0,一句话即可生成整个系统】企业级AI低代码平台,一键生成前后端代码甚至整个系统。 AI Skills 一句话画流程、设计表单、生成报表、大屏。内置 AI…

2026/8/31 20:00:48
exo:把多块设备组成本地AI集群的完整指南,4台Mac跑通671B参数分布式推理

exo:把多块设备组成本地AI集群的完整指南,4台Mac跑通671B参数分布式推理

exo:把多块设备组成本地AI集群的完整指南,4台Mac跑通671B参数分布式推理 【免费下载链接】exo Run frontier AI locally. 项目地址: https://gitcode.com/GitHub_Trending/exo8/exo exo 是一个开源的本地 AI 集群项目:它能把多台 Mac、Linux 服务器组建成一个…

2026/8/31 20:00:48
exo 本地AI集群上手指南:如何把多台设备连起来跑 235B~671B 大模型

exo 本地AI集群上手指南:如何把多台设备连起来跑 235B~671B 大模型

exo 本地AI集群上手指南:如何把多台设备连起来跑 235B~671B 大模型 【免费下载链接】exo Run frontier AI locally. 项目地址: https://gitcode.com/GitHub_Trending/exo8/exo exo 是一个开源分布式推理框架,能把局域网内的多台设备连成一个本地A…

2026/8/31 20:00:48
小米2014校招笔试题解析:一次计算机基础全维度考察

小米2014校招笔试题解析:一次计算机基础全维度考察

每年秋招季,都会有一批经典笔试题在技术社区里被重新翻出来。小米2014校招研发工程师笔试卷A就是其中之一,那会儿正是移动互联网最热的时候,小米的笔试风格在求职圈里出了名的硬核:题目不算偏,但覆盖面极广&#xff0c…

2026/8/31 19:55:48