c# - Azure函数队列触发器

标签 c# azure azure-functions

我如何创建一个队列触发器,它可以从队列中获取项目集合作为触发器。

我当前的队列触发器看起来像

   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/

相关文章:

c# - 在asp.net mvc 3中显示倒计时器

c# - Node : How to generate Rfc2898DeriveBytes like C#?

Azure 数据工厂 - 倍增源 - 仅转换和输出为 JSON

c# - 如何从 C# Core 中的 azure blob 存储读取所有文件

visual-studio - 如何使用调用禁用(未运行)Azure Function 的 VS 部署 Azure 逻辑应用程序?

c# - 在 Azure Functions 中发出故障信号的最佳方式是什么?

c# - 获取xml文件中标签之间的数据

c# - 使用 MongoDB C# 驱动程序 (v2.0) 处理收集事件

c# - 代码在本地 Windows 2008 上运行正常,但无法在 Azure 云上的应用程序数据中创建子文件夹

azure - 在azure函数中包含dll并通过ARM模板将代码移动到资源组中