【发布时间】:2021-03-11 13:42:11
【问题描述】:
我被连接到事件中心的 Azure Functions 卡住了,我发现文档与此无关。
如果我以小 Python 示例为现有事件创建一个循环,以便手动将它们保存到 blob 存储:
from typing import List
import logging
import azure.functions as func
def main(events: List[func.EventHubEvent], outputBlob: func.Out[func.InputStream]):
for event in events:
logging.info('Python EventHub trigger processed an event: %s', event.get_body().decode('utf-8'))
outputBlob.set(event.get_body().decode('utf-8')) # Save to storage.
对于 function.json :
"bindings": [ ...,
{
"type": "blob",
"direction": "out",
"name": "outputBlob",
"path": "outcontainer/{rand-guid}",
"connection": "storage_STORAGE"
}
它可以工作......但不正确:如果事件中有 3 条消息,则保存第一条和第三条消息......但不会保存第二条。有什么方法可以改善这一点,并根据消息的内容使用名称保存每个事件,或者通过根据事件的某些值提供文件名并通过示例在循环中管理来保存其他事件?
谢谢,
【问题讨论】:
-
检查日志有没有错误?
标签: python azure azure-functions azure-blob-storage