Azure CosmosDB 数据触发器不进行实际更新

标签 azure triggers azure-functions azure-cosmosdb azure-cosmosdb-sqlapi

我已使用 CosmosDB 触发器模板创建了一个 Azure 函数,如下所示:this link

工作正常,我可以看到更新从我在 Cosmos DB 中创建的集合中流入。

enter image description here

现在的问题是,我只想要那些有实际更新的文档。目前,如果我使用代码更新文档,它会更新它的时间戳并且文档正在更新。虽然没有实际的数据更新。

我的问题:

  1. 如何才能只获取实际更新的文档(仅那些 json 字段被修改的文档)?
  2. 我怎样才能跟踪已删除的文档?他们也不在这里流动?

最佳答案

1) 由于对文档的任何推送都会更新 - 内部管理 - _ts 属性,这仍然是对整个文档的更改。如果您更改了文档的用户数据,这里也没关系。变更提要不知道这种区别。因此,您也将始终在更改源中看到这些更新。

2) 删除不会添加到更改源中,但有一个可能的解决方法:

Currently change feed doesn’t log deletes. [...] you can add a soft marker on the items that are being deleted, for example, you can add an attribute in the item called "deleted" and set it to "true" and set a TTL on the item, so that it can be automatically deleted.

https://learn.microsoft.com/en-us/azure/cosmos-db/change-feed#change-feed-and-different-operations

关于Azure CosmosDB 数据触发器不进行实际更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56753458/

相关文章:

c# - Azure Webjobs 和 Servicebus 触发器 - nuget 包升级后找不到函数

jQuery onclick 必须单击两次才能出现模式对话框

sql - 使用 SQL Server 触发器在插入后更新另一个表中的列

azure - 使用 NotificationHub 集成在 Visual Studio 上创建的 Azure 函数时出错

用于具有多个订阅主题的服务总线的 Azure ARM 模板

c# - 在 VS Code 中使用 DAPR 运行带有服务总线触发器的 Azure Function 时出错

asp.net-mvc - 开发 localhost 时禁用 Azure Active Directory

mysql - 触发错误 : SQL Error (1193): Unknown system variable 'Showedup'

Botframework v4 函数

azure 函数: set blob filename from http request