我在Azure中有一个MongoDB数据库(已在Cosmos DB帐户下注册),并且在ms docs上读取到每个存储的文档的大小限制为2MB。但是,当我尝试存储大约1.7 MB的图像缓冲区时,出现以下错误:
2019-11-01T00:43:14.057681416Z { MongoError: Message: {"Errors":["Request size is too large"]}
2019-11-01T00:43:14.057757320Z RequestStartTime: 2019-11-01T00:43:13.9695930Z, RequestEndTime: 2019-11-01T00:43:13.9995776Z, Number of regions attempted:1
2019-11-01T00:43:14.057768921Z ResponseTime: 2019-11-01T00:43:13.9995776Z, StoreResult: StorePhysicalAddress: rntbd://cdb-ms-prod-centralus1-fd19.documents.azure.com:14112/apps/0806fa15-6a2d-4127-a73b-b1626ddd8af1/services/5618d8a3-dc06-4e8a-ba18-39d3b0c58add/partitions/d61f7139-78bf-423b-a4d7-747179270393/replicas/132167814077711166p/, LSN: -1, GlobalCommittedLsn: -1, PartitionKeyRangeId: , IsValid: True, StatusCode: 410, SubStatusCode: 0, RequestCharge: 0, ItemLSN: -1, SessionToken: , UsingLocalLSN: False, TransportException: null, ResourceType: Document, OperationType: Create
2019-11-01T00:43:14.057779921Z SDK: Microsoft.Azure.Documents.Common/2.7.0
2019-11-01T00:43:14.057788121Z at Function.create (/home/site/wwwroot/node_modules/mongodb/lib/core/error.js:44:12)
2019-11-01T00:43:14.057796322Z at toError (/home/site/wwwroot/node_modules/mongodb/lib/utils.js:150:22)
2019-11-01T00:43:14.057804822Z at coll.s.topology.insert (/home/site/wwwroot/node_modules/mongodb/lib/operations/common_functions.js:266:39)
2019-11-01T00:43:14.057813223Z at handler (/home/site/wwwroot/node_modules/mongodb/lib/core/sdam/topology.js:1000:24)
2019-11-01T00:43:14.057821223Z at wireProtocol.(anonymous function) (/home/site/wwwroot/node_modules/mongodb/lib/core/sdam/server.js:457:5)
2019-11-01T00:43:14.057829423Z at /home/site/wwwroot/node_modules/mongodb/lib/core/connection/pool.js:408:18
2019-11-01T00:43:14.057837624Z at process._tickCallback (internal/process/next_tick.js:61:11)
2019-11-01T00:43:14.057845624Z driver: true,
2019-11-01T00:43:14.057853424Z name: 'MongoError',
2019-11-01T00:43:14.057861125Z index: 0,
2019-11-01T00:43:14.057868725Z code: 16,
2019-11-01T00:43:14.057876326Z errmsg:
2019-11-01T00:43:14.057886326Z 'Message: {"Errors":["Request size is too large"]}\r\n, RequestStats: \r\nRequestStartTime: 2019-11-01T00:43:13.9695930Z, RequestEndTime: 2019-11-01T00:43:13.9995776Z, Number of regions attempted:1\r\nResponseTime: 2019-11-01T00:43:13.9995776Z, LSN: -1, GlobalCommittedLsn: -1, PartitionKeyRangeId: , IsValid: True, StatusCode: 410, SubStatusCode: 0, RequestCharge: 0, ItemLSN: -1, SessionToken: , UsingLocalLSN: False, TransportException: null, ResourceType: Document, OperationType: Create\r\n, SDK: Microsoft.Azure.Documents.Common/2.7.0',
2019-11-01T00:43:14.057902127Z [Symbol(mongoErrorContextSymbol)]: {} }
当前,我正在订阅Azure for Students
,并且我一直在使用免费套餐来获取所有资源。我也读过this documentation的存储和吞吐量,但是我不确定为了使工作正常我需要修改什么。
有人可以建议吗?
答案 0 :(得分:2)
文档的最大大小为2 MB,无法增加。您可以将图像存储在Blob存储中,并将url作为属性附加到要保存的文档中,这将节省几个字节。
答案 1 :(得分:1)
在Cosmos DB中存储文档时,会进行编码。我怀疑您的二进制数据在进行编码(扩展其存储大小)时,将成为导致文档大小远远超出预期(并且超出2MB大小限制)的问题。
正如@sajeetharan所提到的,还有其他方法来存储二进制数据(例如blob,在Cosmos DB文档中仅具有参考uri),这将有助于减小blob的大小。
您的订阅类型与Cosmos DB的文档大小限制无关。
答案 2 :(得分:0)