快速入门:使用 Azure 门户创建 Azure Cosmos DB for MongoDB vCore 群集

适用对象: MongoDB vCore

在本快速入门中,你将创建新的 Azure Cosmos DB for MongoDB vCore 群集。 此群集包含所有 MongoDB 资源:数据库、集合和文档。 该群集为各种工具和 SDK 提供唯一终结点,用于连接到 Azure Cosmos DB 并执行日常操作。

先决条件

创建群集

使用 Azure Cosmos DB for MongoDB vCore 创建 MongoDB 群集。

提示

对于本指南,建议使用资源组名称 msdocs-cosmos-quickstart-rg

  1. 登录 Azure 门户

  2. 在 Azure 门户菜单或主页中,选择“创建资源” 。

  3. 在“新建”页面中搜索“Azure Cosmos DB”,然后选择它。

  4. 在“哪种 API 最适合你的工作负载?”页上,在“Azure Cosmos DB for MongoDB”部分中选择“创建”选项。 有关详细信息,请参阅用于 MongoDB 的 API 及其各种模型

    Screenshot of the select API option page for Azure Cosmos DB.

  5. 在“哪种类型的资源?”页上,选择 vCore 群集部分中的“创建”选项。 有关详细信息,请参阅 API for MongoDB vCore 概述

    Screenshot of the select resource type option page for Azure Cosmos DB for MongoDB.

  6. 在“创建 Azure Cosmos DB for MongoDB 群集”页上,选择“群集层”部分中的“配置”选项。

    Screenshot of the configure cluster option for a new Azure Cosmos DB for MongoDB cluster.

  7. 在“缩放”页上,将选项设置为默认值:

    设置 “值”
    分片计数 单个分片
    群集层 M30 层,2 个 vCore,8 GiB RAM
    每个分片的存储 128 GiB
  8. 将“高可用性”选项保持在未选中状态。 在“高可用性 (HA) 确认”部分中,选择“我了解”。 最后,选择“保存”,将更改保存到群集层。

    Screenshot of cluster tier and scale options for a cluster.

  9. 返回群集页,输入以下信息:

    设置 说明
    订阅 订阅名称 选择要用于此 Azure Cosmos DB for MongoDB 群集的 Azure 订阅。
    资源组 资源组名称 选择一个资源组,或者选择“新建”,然后输入新资源组的唯一名称。
    群集名称 唯一的名称 输入用于标识你的 Azure Cosmos DB for MongoDB 群集的名称。 该名称用作后缀为“documents.azure.cn”的完全限定域名 (FQDN) 的一部分,因此该名称必须在多个区域中唯一。 名称只能包含小写字母、数字和连字符 (-)。 名称的长度也必须介于 3 - 44 个字符之间。
    位置 离用户最近的区域 选择用于托管 Azure Cosmos DB for MongoDB 群集的地理位置。 使用离用户最近的位置,使他们能够以最快的速度访问数据。
    MongoDB 版本 要在群集中运行的 MongoDB 的版本 默认情况下,此值设为 5.0
    管理员用户名 提供用于访问群集的用户名 此用户以用户管理员身份在群集上创建。
    密码 使用唯一密码与用户名配对 密码必须至少为 8 个字符,最多 128 个字符。

    Screenshot of various configuration options for a cluster.

  10. 在完成时选择“下一步: 网络”。

  11. 在“网络”部分中,选择“允许从 Azure 服务进行公共访问”。 此外,添加防火墙规则以授予客户端设备或应用程序对群集的访问权限。

    Screenshot of networking and firewall options for a cluster.

    注意

    在许多企业环境中,开发人员计算机 IP 由于 VPN 而隐藏。 在这些情况下,建议先允许访问所有 IP 进行连接测试,然后再优化允许列表。

  12. 选择“查看 + 创建”。

  13. 查看提供的设置,然后选择“创建”。 创建群集需要几分钟时间。 等待门户页显示“部署已完成”后再继续。

  14. 选择“转到资源”,转到 Azure Cosmos DB for MongoDB 群集页。

    Screenshot of the deployment page for a cluster.

获取群集凭据

使用应用程序代码获取连接到此群集所需的连接字符串。

  1. 从 Azure Cosmos DB for MongoDB vCore 群集页中,选择“连接字符串”导航菜单选项。

    Screenshot of the connection strings option on the page for a cluster.

  2. 记录“连接字符串”字段的值。

    Screenshot of the connection string credential for a cluster.

    重要

    门户中的连接字符串不包括用户名和密码值。 必须将 <user><password> 占位符替换为最初创建群集时使用的凭据。

清理资源

执行完 Azure Cosmos DB for MongoDB vCore 群集的操作以后,可以删除所创建的 Azure 资源,以免产生更多费用。

  1. 在 Azure 门户的“搜索”栏中,搜索并选择“资源组”。

  2. 在列表中选择为本快速入门使用的资源组。

    Screenshot of a list of resource groups filtered down to a specific prefix.

  3. 在资源组页上,选择“删除资源组”

    Screenshot of the delete resource group option in the menu for a specific resource group.

  4. 在删除确认对话框中,输入资源组的名称以确认要删除它。 最后,选择“删除”以永久删除资源组。

    Screenshot of the delete resource group confirmation dialog with the name of the group filled out.

下一步

在本指南中,你了解了如何创建 Azure Cosmos DB for MongoDB vCore 群集。 现在可以将数据迁移到群集。