[英]Azure function - multiple files coming in storage blob at the same time: how to make them be processed sequentially
I'm building a solution who extract data from invoice PDF with the Microsoft Form Recgnizer Api and add the information to an SQL Database.我正在构建一个解决方案,该解决方案使用 Microsoft Form Recgnizer Api 从发票 PDF 中提取数据,并将信息添加到 SQL 数据库中。
I build a parser and a code who add rows from the API response to a database when a pdf is uploaded in my storage blob with success.我构建了一个解析器和一个代码,当 pdf 成功上传到我的存储 blob 时,将 API 响应中的行添加到数据库。
I'm looking for the easiest way to handle multiple PDF coming at the same time in my database.我正在寻找最简单的方法来处理数据库中同时出现的多个 PDF。
I'm facing deadlocks issues when i make a test with multiple pdf incoming because there is process conflict in SQL server: if i upload 4 pdf, the 4 PDF are processed a the same time and are being parsed and data added to SQL at the same time, which cause conflict and potentially non logical arrangement of the database rows (i don't want to make an update group By invoice number after each process to re arrange the whole table).当我对多个 pdf 传入进行测试时,我面临死锁问题,因为 SQL 服务器中存在进程冲突:如果我上传 4 个 pdf,则同时处理 4 个 PDF 并正在解析并将数据添加到 SQL同时,这会导致数据库行的冲突和潜在的非逻辑排列(我不想在每个过程后按发票号更新组以重新排列整个表)。
Now, i'm looking at a solution who can take every element incoming in storage blob one after another, instead of all at the same time.现在,我正在寻找一种解决方案,它可以一个接一个地获取存储 blob 中的每个元素,而不是同时获取所有元素。 Something like a For loop who iterate sequentially on every blob "source" and send them in entry for my parsing function.
类似于 For 循环,它在每个 blob“源”上按顺序迭代并将它们发送到入口以供我解析 function。
Or something like a queue who could work like this:或者类似队列的东西可以像这样工作:
PDF1, PDF2, PDF3 incoming in storage blob: PDF1、PDF2、PDF3 传入存储 blob:
Make PDF2 and PDF3 waiting, send PDF1 to API analyse, add data to SQL and when last row added, send PDF2 to API analyse, add data to SQL and when last row added, send PDF3 etc让 PDF2 和 PDF3 等待,发送 PDF1 到 API 分析,添加数据到 SQL 当添加最后一行时,发送 PDF2 到 API 分析,添加数据到 SQL 当添加最后一行时,发送 PDF3 等
Thanks for your suggestion:)谢谢你的建议:)
You can route Azure blob storage events to an Azure Function. https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blob-event-overview您可以将 Azure blob 存储事件路由到 Azure Function。https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blob-event-overview
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.