简体   繁体   中英

Document Db Usage on Azure

In our project, we try to store big files, like images, in our nosql database. While making some researches, we hear of Document Db nosql database in Azure Cloud Platform. Additionally, we will store our datas in Azure.

What is the best way storing big files in Azure Platform?, Document Db is good enough?, Is it appropriate using MongoDb in Azure?

Though DocumentDB allows you to store files (they are stored as attachments), I would not recommend using it. Here are my reasons:

  • In the current version, the maximum size of an attachment is 2 MB.
  • You can't really stream attachments. You would need to first read the attachment contents in your application and stream it from there.

For storing files in Azure, I would highly recommend that you use Blob Storage . It is meant for that purpose only. Maximum size of a file that you can store in blob storage is 1 TB (which I would assume would be more than sufficient for you) and each storage account could hold up to 500 TB of data. Furthermore you can directly stream files to your end users.

DocumentDB does allow you to add files to your documents, called attachments . The advantage of using that feature is that the storage of your attachment is tied to the lifecycle of your document: if you delete the document, then the attachment will be deleted as well.

As DocDB is still in preview, you can expect the aforementioned limitations to be different once the service goes into General Availability.

You do not have to store the attachments in DocDB itself. DocDB allows you to do that, or to simple store a reference to your file as part of the attachment's metadata. This is useful is you want to store your file somewhere else, but need a reference to its location within the DocDB document. From the documentation :

DocumentDB allows you to store binary blobs/media either with DocumentDB or to your own remote media store . It also allows you to represent the metadata of a media in terms of a special document called attachment. An attachment in DocumentDB is a special (JSON) document which references the media/blob stored elsewhere. An attachment is simply a special document which captures the metadata (eg location, author etc.) of a media stored in a remote media storage.

If you need to store really big files into Azure (like video files or big engineering files), your best (and cheapest) option is probably to store your data in a Block Blob. You can then take the Uri of the blob and store it as an attachment metadata within your docdb document.

The preferable mechanism to store files would be Blob Storage as it is cheap. Keep in mind that Document DB is really expensive so event o store the file path in Blob Storage use Azure Tables.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM