共用方式為


快速入門:使用 Azure 入口網站建立 Azure Cosmos DB for MongoDB 虛擬核心叢集

適用於: MongoDB 虛擬核心

在本快速入門中,您會建立新的 Azure Cosmos DB for MongoDB 虛擬核心叢集。 此叢集包含您的所有 MongoDB 資源:資料庫、集合和文件。 此叢集為各種工具和 SDK 提供唯一的端點,用以連線至 Azure Cosmos DB 並執行日常作業。

必要條件

建立叢集

使用 Azure Cosmos DB for MongoDB 虛擬核心建立 MongoDB 叢集。

提示

針對本指南,我們建議使用資源組名稱 msdocs-cosmos-quickstart-rg

  1. 登入 Azure 入口網站

  2. 從 Azure 入口網站功能表或 [首頁] 頁面,選取 [建立資源]

  3. 在 [新增] 頁面上,搜尋並選取 [Azure Cosmos DB]

  4. 在 [哪個 API 最適合您的工作負載?] 頁面上,選取 [Azure Cosmos DB for MongoDB] 區段內的 [建立] 選項。 如需詳細資訊,請參閱 API for MongoDB 及其各種模型

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

  5. 在 [哪種資源類型?] 頁面上,選取 [虛擬核心叢集] 區段中的 [建立] 選項。 如需詳細資訊,請參閱 API for MongoDB 虛擬核心概觀

    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 個虛擬核心、8 GiB RAM
    每個分區的儲存體 128 GiB
  8. 將 [高可用性] 選項保留為未選取。 在高可用性 (HA) 通知區段中,選取 [我了解]。 最後,選取 [儲存] 以將變更保存到叢集層。

    Screenshot of cluster tier and scale options for a cluster.

  9. 回到叢集頁面,輸入下列資訊:

    設定 Description
    訂用帳戶 訂用帳戶名稱 選取要用於此 Azure Cosmos DB for MongoDB 叢集的 Azure 訂用帳戶。
    資源群組 資源群組名稱 選取資源群組,或選取 [新建],然後輸入新資源群組的唯一名稱。
    叢集名稱 唯一名稱 輸入名稱來識別您的 Azure Cosmos DB for MongoDB 叢集。 名稱會作為完整網域名稱 (FQDN) 的一部分,其尾碼為 documents.azure.com,因此名稱必須是全域唯一。 名稱只能包含小寫字母、數字及連字號 (-) 字元。 且名稱長度必須介於 3 到 44 個字元之間。
    Location 最接近使用者的區域 選取用來裝載 Azure Cosmos DB for MongoDB 叢集的地理位置。 使用最接近使用者的位置,讓他們能以最快速度存取資料。
    MongoDB 版本 要在您的叢集中執行的 MongoDB 版本 此值設定為預設值 5.0
    管理員使用者名稱 提供存取叢集的使用者名稱 此使用者以使用者管理員身分建立在叢集上。
    密碼 使用唯一密碼與使用者名稱配對 密碼長度必須至少為八個字元,最多 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 虛擬核心叢集頁面中,選取 [連接字串] 導覽功能表選項。

    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 虛擬核心叢集後,您可以將建立的 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 虛擬核心叢集。 現在,您可以將資料移轉至您的叢集。