我如何创建一个队列触发器,它可以从队列中获取项目集合作为触发器。
我当前的队列触发器看起来像
public static async Task Run(
[QueueTrigger("socmapping")]
SocMapping myQueueItem,
[Queue("socmapping-invalid")]
IAsyncCollector<SocMapping> invalidSocMappings,
TraceWriter log,
[Queue("projectedavfeedforsocmapping")]
IAsyncCollector<ProjectedVacancySummary> projectedVacancySummary,
[DocumentDB("AVFeedAudit", "AuditRecords", ConnectionStringSetting = "AVAuditCosmosDB")]
IAsyncCollector<AuditRecord<object, object>> auditRecord)
但我想要类似的东西(可以从队列中获取n个项目)[下面的代码抛出异常并说它是json数组]
public static async Task Run(
[QueueTrigger("socmapping")]
***List<SocMapping> myQueueItem,***
[Queue("socmapping-invalid")]
IAsyncCollector<SocMapping> invalidSocMappings,
TraceWriter log,
[Queue("projectedavfeedforsocmapping")]
IAsyncCollector<ProjectedVacancySummary> projectedVacancySummary,
[DocumentDB("AVFeedAudit", "AuditRecords", ConnectionStringSetting = "AVAuditCosmosDB")]
IAsyncCollector<AuditRecord<object, object>> auditRecord)
因为我想对队列项目进行批处理,并且只有在队列中存在任何项目时才应触发该函数。想要从队列中取出(10)并处理触发函数。
我怎样才能实现这个目标?
最佳答案
这是不可能的。队列中的每条消息都会触发您的 Azure 函数一次。某些触发器类型支持批处理参数(例如事件中心或 Cosmos DB),但队列触发器不是其中之一。
关于c# - Azure函数队列触发器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51783646/