【发布时间】:2021-05-05 00:17:39
【问题描述】:
有没有机会在我的 python Azure 函数中读取一堆消息(使用 serviceBusTrigger)?
这个问题很简单。我做了很多尝试,但似乎 Azure 函数框架在读取来自 Azure 服务总线的消息后,一次调用触发函数一条消息,无论预取值有多大或设置了任何参数。
我想处理整个消息获取,因为当您必须处理数百万条消息时,一次一条或一次多条会产生影响。
这是我的配置:
function.json
{
"scriptFile": "main.py",
"entryPoint": "function_handler",
"bindings": [{
"name": "msg",
"type": "serviceBusTrigger",
"direction": "in",
"topicName": "topic-name",
"subscriptionName": "topic-subscription-name"
}]
}
main.py
import azure.functions as func
import json
def function_handler(msg: func.ServiceBusMessage):
print(str(msg))
host.json
{
"version": "2.0",
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[1.*, 2.0.0)"
},
"extensions": {
"serviceBus": {
"prefetchCount": 100,
"messageHandlerOptions": {
"autoComplete": true,
"maxConcurrentCalls": 6,
"maxAutoRenewDuration": "00:05:00"
}
}
}
}
【问题讨论】:
标签: python azure-functions azureservicebus