如何将 Azure CosmosDB 模拟器与 MongoDB API 结合使用?

问题描述

我使用 Microsoft Azure COMOS 模拟器版本 2.11.11.0。我用命令行启动它:

CosmosDB.Emulator.exe /EnableMongoDbEndpoint=3.6

如果我用我的应用程序连接到 MongoDB 端点,我会收到以下错误:

com.mongodb.MongoCommandException: Command failed with error 1 (InternalError):
 '[ActivityId=64bdb726-f138-4025-8d5b-ca23bbda384c] Internal error.' on server localhost:10255.
 The full response is {"ok": 0.0,"errmsg": "[ActivityId=64bdb726-f138-4025-8d5b-ca23
bbda384c] Internal error.","code": 1,"codeName": "InternalError"}

这个错误是什么意思?我还需要做什么才能使用 MongoDB API?

失败是第一个写命令:

'{"createIndexes": "fs.files","indexes": [{"key": {"filename": 1},"name": "filename_1","ns": "admin.fs.files"}],"$db": "admin","lsid": {"id": {"$binary": {"base64": "lFHKYPJ0Rq+ip587pl8YPQ==","subType": "04"}}},"$readPreference": {"mode
": "primaryPreferred"}}'

它是从简单的 Java 代码行产生的:

collection.createIndex( new BasicDBObject( FILENAME,1 ) );

PS:使用 MongoDb 端点 3.2,这是有效的。一定是模拟器有问题。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)