【问题标题】:Azure function Queue TriggerAzure 函数队列触发器
【发布时间】:2018-08-10 09:45:21
【问题描述】:

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

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

   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)并处理触发函数。

我怎样才能做到这一点?

【问题讨论】:

    标签: c# azure azure-functions


    【解决方案1】:

    这是不可能的。队列中的每条消息都会触发一次 Azure 函数。某些触发器类型支持批处理参数(例如 Event Hubs 或 Cosmos DB),但队列触发器不是其中之一。

    【讨论】:

    • 谢谢米哈伊尔。为了解决这个问题,我创建了一个对象集合并存储在一个队列中,而不是单个项目。
    猜你喜欢
    • 1970-01-01
    • 2021-03-01
    • 1970-01-01
    • 2021-10-30
    • 1970-01-01
    • 2018-03-26
    • 2018-07-10
    • 2021-07-07
    • 2019-08-04
    相关资源
    最近更新 更多