Azure功能中宇宙DB的输出绑定中的并发如何管理?
我有一个函数应用程序,它具有2个函数,函数1 是httptrigger函数,并在http呼叫受到击中时运行,然后将有效负载发送到服务总线并完成其执行。
另一个函数 function2 在服务总线队列中发布某些内容时运行,然后检查cosmosdb中的相应数据,如果它已经存在在数据库中。
我面临的问题是,如果在httptrigger函数上提出了2个请求,那么只执行其中一个请求,我想检查是否有一种方法可以在COSMOSDB操作中寻找并发。
COSMOSDB上的更新操作通过输出绑定。
context.bindings.outputdocument =更新Document
I have a function app and it has 2 functions in it, Function1 which is an HTTPTrigger function and runs when an HTTP call is hit on it, it then sends the payload to service bus and completes its execution.
Another function Function2 runs when something is published in the service bus queue and it then checks the corresponding data in the CosmosDB and if it is already present then it updates some keys in it otherwise, it creates a new document in the database.
The problem I am facing is that if 2 requests are made on the HTTPTrigger function then only one of those are executed, I want to check if there is a way I can look for concurrency in the CosmosDB operation.
The update operation on cosmosDB is through the output binding.
context.bindings.outputDocument = updatedDocument
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
输出绑定仅执行UPSERT操作。如果您两次将同一文档(相同的ID和分区键值)提高,则仍然是一个文档(首先UPSERT创建文档,第二个UPSERT更新)。
并发基于触发器及其如何执行,在您的情况下,它取决于HTTP触发器以及它如何处理并发请求。 upserts是顺序或并发,但是从输出绑定的角度来看,这并不重要,每个都是一个独立的upsert调用。
Output binding just performs an Upsert operation. If you Upsert the same document (same id and partition key value) twice, it's still a single document (first Upsert creates the document, second Upsert updates it).
Concurrency is based on the Triggers and how they execute, in your case, it depends on the HTTP Trigger and how it handles concurrent requests. Either the Upserts are sequential or concurrent, but from the Output Binding perspective it doesn't matter, each is an independent Upsert call.