且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Azure Blob存储的事务访问

更新时间:2023-02-08 23:14:46

据我所知,没有内置的功能可以做到这一点.您将需要自己进行管理.最简单的方案是先保存您的Blob,然后添加数据库记录.由于数据库是满足您需求的索引,因此在保存数据库记录之前,Blob对于您的代码基本上是不可见的.

There is nothing built-in that will do this as far as I know; you will need to manage this yourself. The simplest scenario is to save your blob first, then add your database record. Since the database serves as an index for your needs, the Blob is essentially invisible to your code until the database records gets saved.

一个更复杂的选择是实现自己的提交逻辑.您将处理数据库插入(例如,将记录上的标志设置为0),保存Blob,如果成功,则将数据库中的标志设置为1.

A more involved option is to implement your own commit logic. You would handle a database insert (with a flag on the record set to 0 for example), save the Blob, and if successful set the flag in the database to 1.

您也可以将元数据保存在Azure表中,但是如果您有很多记录,则在Azure表中搜索会大大减慢速度.在大多数情况下,在SQL数据库中搜索会更快.

You could also save the metadata in Azure Tables, although searching in Azure Tables can slow down significantly if you have lots of records. Searching in SQL Database will be faster most of the time.

您选择哪种方法取决于您的目标,但我认为第一种选择是最简单的.

Which approach you choose depends on your objectives, but I think the first option is the simplest.