【问题标题】:How to distinguish between delete update create in cosmosdb trigger to azure function如何区分 cosmosdb 触发器中的删除更新创建到天蓝色函数
【发布时间】:2021-06-23 09:31:41
【问题描述】:

我在 cosmosdb 上创建了一个触发器到 azure 中的 azure 函数,我在文档中找不到如何区分删除、更新和创建的任何内容

{
  "bindings": [
    {
      "type": "cosmosDBTrigger",
      "name": "input",
      "direction": "in",
      "leaseCollectionName": "leases",
      "connectionStringSetting": "pcmDevValidAppsTrigger_ConnectionString",
      "databaseName": "pcmobile-dev",
      "collectionName": "validApps",
      "createLeaseCollectionIfNotExists": true
    }
  ]
}
module.exports = async (context, documents) => {
    context.log('Document Id: ', documents[0].id);
}

【问题讨论】:

    标签: azure azure-functions azure-cosmosdb


    【解决方案1】:

    根据文档,您不能:https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-cosmosdb-v2-trigger - 触发器使用更改提要,更改提要当前仅包括插入和更新 (https://docs.microsoft.com/en-us/azure/cosmos-db/change-feed#features-of-change-feed):

    更改提要包括对容器内的项目进行的插入和更新操作。您可以通过在您的项目(例如,文档)中设置“软删除”标志来代替删除来捕获删除。或者,您可以使用 TTL 功能为您的项目设置一个有限的有效期。例如,24 小时并使用该属性的值来捕获删除。使用此解决方案,您必须在比 TTL 过期期限更短的时间间隔内处理更改。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-10-10
      • 2021-03-23
      • 2018-12-27
      • 1970-01-01
      • 2021-08-12
      • 1970-01-01
      • 2018-07-15
      相关资源
      最近更新 更多