gpt4 book ai didi

azure - 如何区分cosmosdb触发器中的delete update create到azure函数

转载 作者:行者123 更新时间:2023-12-02 23:15:57 25 4
gpt4 key购买 nike

我在 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);
}

最佳答案

根据文档,您不能:https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-cosmosdb-v2-trigger - 触发器消耗 Change Feed,且 Change Feed 目前仅包含插入和更新 ( https://learn.microsoft.com/en-us/azure/cosmos-db/change-feed#features-of-change-feed ):

The change feed includes inserts and update operations made to items within the container. You can capture deletes by setting a "soft-delete" flag within your items (for example, documents) in place of deletes. Alternatively, you can set a finite expiration period for your items with the TTL capability. For example, 24 hours and use the value of that property to capture deletes. With this solution, you have to process the changes within a shorter time interval than the TTL expiration period.

关于azure - 如何区分cosmosdb触发器中的delete update create到azure函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66818881/

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