有关适用于 MongoDB 的 Azure Cosmos DB API 的常见问题解答Frequently asked questions about the Azure Cosmos DB's API for MongoDB

Azure Cosmos DB 的 API for MongoDB 是一个线路协议兼容层,允许应用程序使用现有的、社区支持的 SDK 和用于 MongoDB 的驱动程序轻松、透明地与本机 Azure Cosmos 数据库引擎通信。The Azure Cosmos DB's API for MongoDB is a wire-protocol compatibility layer that allows applications to easily and transparently communicate with the native Azure Cosmos database engine by using existing, community-supported SDKs and drivers for MongoDB. 开发人员现在可以使用现有的 MongoDB 工具链和技术,生成能够充分利用 Azure Cosmos DB 的应用程序。Developers can now use existing MongoDB toolchains and skills to build applications that take advantage of Azure Cosmos DB. 开发人员可以使用 Azure Cosmos DB 的独特功能,其中包括带多主数据库复制功能的多区域分发、自动索引、备份维护、获得财务支持的服务级别协议 (SLA) 等。Developers benefit from the unique capabilities of Azure Cosmos DB, which include multiple-region distribution with multi-master replication, auto-indexing, backup maintenance, financially backed service level agreements (SLAs) etc.

如何连接到数据库?How do I connect to my database?

若要通过 Azure Cosmos DB 的用于 MongoDB 的 API 连接到 Cosmos 数据库,最快捷的方法是使用 Azure 门户The quickest way to connect to a Cosmos database with Azure Cosmos DB's API for MongoDB is to head over to the Azure portal. 转到帐户,然后在左侧导航菜单上单击“快速启动”。****Go to your account and then, on the left navigation menu, click Quick Start. 快速入门是获取连接到数据库的代码片段的最佳方式。Quickstart is the best way to get code snippets to connect to your database.

Azure Cosmos DB 实施严格的安全要求和标准。Azure Cosmos DB enforces strict security requirements and standards. Azure Cosmos DB 帐户需要通过 TLS 进行身份验证和安全通信,因此务必使用 TLSv1.2。Azure Cosmos DB accounts require authentication and secure communication via TLS, so be sure to use TLSv1.2.

有关详细信息,请参阅通过 Azure Cosmos DB 的用于 MongoDB 的 API 连接到 Cosmos 数据库For more information, see Connect to your Cosmos database with Azure Cosmos DB's API for MongoDB.

在使用适用于 MongoDB 的 Azure Cosmos DB API 时出现错误代码?Error codes while using Azure Cosmos DB's API for MongoDB?

除了常见的 MongoDB 错误代码外,Azure Cosmos DB 的用于 MongoDB 的 API 还有自己的特定错误代码:Along with the common MongoDB error codes, the Azure Cosmos DB's API for MongoDB has its own specific error codes:

错误Error 代码Code 说明Description 解决方案Solution
TooManyRequestsTooManyRequests 1650016500 使用的请求单位总数超过了容器的预配请求单位率,已被限制。The total number of request units consumed is more than the provisioned request-unit rate for the container and has been throttled. 考虑从 Azure 门户中对分配给一个容器或一组容器的吞吐量进行缩放,或者重试。Consider scaling the throughput assigned to a container or a set of containers from the Azure portal or retrying again.
ExceededMemoryLimitExceededMemoryLimit 1650116501 作为一种多租户服务,操作已超出客户端的内存配额。As a multi-tenant service, the operation has gone over the client's memory allotment. 通过限制性更强的查询条件缩小操作的作用域,或者通过 Azure 门户联系技术支持。Reduce the scope of the operation through more restrictive query criteria or contact support from the Azure portal.

示例: db.getCollection('users').aggregate([{$match: {name: "Andy"}}, {$sort: {age: -1}}]))Example: db.getCollection('users').aggregate([{$match: {name: "Andy"}}, {$sort: {age: -1}}]))

支持的驱动程序Supported drivers

是否支持将 MongoDB 的 Simba 驱动程序与 Azure CosmosDB 的用于 MongoDB 的 API 一起使用?Is the Simba driver for MongoDB supported for use with Azure Cosmos DB's API for MongoDB?

是的,可以将 Simba 的 Mongo ODBC 驱动程序与 Azure Cosmos DB 的用于 MongoDB 的 API 一起使用Yes, you can use Simba's Mongo ODBC driver with Azure Cosmos DB's API for MongoDB

后续步骤Next steps