【问题标题】:Publishing events to azure event grid via azure functions通过 azure 函数将事件发布到 azure 事件网格
【发布时间】:2021-11-02 16:51:17
【问题描述】:

我想从 azure 函数将事件发布到 azure 事件网格。其他 azure 函数将消耗这些事件。

是否可以仅使用 azure 函数触发事件网格事件?

【问题讨论】:

标签: azure azure-functions azure-eventgrid


【解决方案1】:

借助Azure Event Grids,我们可以轻松构建基于事件的架构。

集成Event Grid with Azure functions有两个关键点,看一下我们可以与多种语言交互的文档。

  1. Trigger
  2. Output binding

EventGridPublisherClient、EventGridEvent是我们在Python中使用的客户端,我们从azure.eventgrid中导入

下面是我们在python中处理事件的方式

key = os.environ["EG_ACCESS_KEY"]
endpoint = os.environ["EG_TOPIC_HOSTNAME"]

# authenticate client
credential = AzureKeyCredential(key)
client = EventGridPublisherClient(endpoint, credential)

有关详细信息,请参阅 Azure SDK for Python 中的 Python Source code

【讨论】:

    猜你喜欢
    • 2021-02-18
    • 2018-12-12
    • 1970-01-01
    • 1970-01-01
    • 2019-08-05
    • 1970-01-01
    • 1970-01-01
    • 2020-11-02
    • 2022-01-08
    相关资源
    最近更新 更多