gpt4 book ai didi

azure - CosmosDbTrigger 仅过滤插入?

转载 作者:行者123 更新时间:2023-12-01 09:02:34 25 4
gpt4 key购买 nike

我有一个非常简单的 azure 函数,并设置了 CosmosDbTrigger(几乎直接取自示例,只是作为最小的重现):

[FunctionName("ProcessEmail")]
public static void Run([CosmosDBTrigger("mydb", "mycollection")]IReadOnlyList<Document> documents, TraceWriter log)
{
log.Verbose("Documents modified " + documents.Count);
log.Verbose("First document Id " + documents[0].Id);
}

这设置起来非常简单并且工作完美。

但是,就我而言,我只希望在插入记录时收到通知,而不是在更新记录时收到通知。

  1. 是否可以仅在插入文档时触发?
  2. 如果不是,是否可以根据每个文档判断触发此运行的是插入还是更新?
  3. 如果没有,我最好的选择是什么?文档上是否有一个标记,表明该阶段是否已处理?

最佳答案

我们在其中一个函数应用中对仅更新 CosmosDB 触发器有类似的要求。然而,我们最终使用了一个标志,因为根据 docs 尚不支持控制更改源。 .

Today, you see all operations in the change feed. The functionality where you can control change feed, for specific operations such as updates only and not inserts is not yet available. You can add a “soft marker” on the item for updates and filter based on that when processing items in the change feed.

关于azure - CosmosDbTrigger 仅过滤插入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47268262/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com