错误:使用pydocumendb将数据上传到Cosmosdb

时间:2018-05-30 14:39:31

标签: python python-2.7 azure azure-cosmosdb azure-cosmosdb-sqlapi

我正在使用pydocumentdb将一些已处理的数据作为Azure云上的文档上传到CosmosDB,并附带Python脚本。这些文件来自同一个来源。摄取适用于某些文件,但会为大于1000 KB的文件提供下一个错误:

 pydocumentdb.errors.HTTPFailure: Status code: 413
 "code":"RequestEntityTooLarge","message":"Message: {\"Errors\":[\"Request 
 size is too large\"]

我正在使用SQL API,这就是我在Collection中创建文档的方式:

client = document_client.DocumentClient(uri, {'masterKey': cosmos_key})
... I get the Db link and Collection link ...
Client.CreateDocument(collection_link, data)

如何解决此错误?

1 个答案:

答案 0 :(得分:0)

根据我的经验,要在Azure Cosmos DB上存储一些大型数据或文件,最佳做法是将数据上传到Azure Blob存储或其他外部存储,并在Azure上的文档中创建包含其引用或关联元数据的附件Cosmos DB。

您可以参考Attachments的REST API来了解它并使用PyDocument API包括CreateAttachmentReplaceAttachment,{{shell.run with variable的方法来实现您的需求功能1}}等等。

希望它有所帮助。