azure - CosmosDbTrigger 仅过滤插入?

标签 azure azure-cosmosdb azure-functions

我有一个非常简单的 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/

相关文章:

c# - Azure 事件中心 - 如何在 .Net Core WebAPI 中实现使用者?

azure-cosmosdb - null 元素应该存储在 Cosmos DB 中还是应该被忽略?

azure - 如何将 Azure 功能从应用服务计划移至消费计划

java - BlobInput 的 Azure 函数绑定(bind)问题,没有任何错误

f# - 使用 F# 进行多字段验证(在 azure 函数中)

python - 使用 python 将抓取的数据直接保存到 azure blob 存储

azure - 如何在 azure 搜索中对复杂 json 对象(例如嵌套数组)进行字段映射

c# - Windows Azure 中的数据库连接

azure - DocumentDb "where"带有数学表达式的子句

azure - CosmosDb 搜索索引与分区键