分享方式:


在適用於 MongoDB 的 Azure Cosmos DB for MongoDB 資源上佈建資料庫、容器或自動調整輸送量

適用於: MongoDB

此文章說明如何在 Azure Cosmos DB for MongoDB 中佈建輸送量。 您可以在容器或資料庫上佈建標準 (手動) 或自動調整輸送量,並在資料庫內的容器之間共用。 您可以使用 Azure 入口網站、Azure CLI 或 Azure Cosmos DB SDK 來佈建輸送量。

如果您使用不同的 API,請參閱 API for NoSQLAPI for CassandraAPI for Gremlin 文章來佈建輸送量。

Azure 入口網站

  1. 登入 Azure 入口網站

  2. 建立新的 Azure Cosmos DB 帳戶,或選取現有的 Azure Cosmos DB 帳戶。

  3. 開啟 [資料總管] 窗格,然後選取 [新增集合]。 接下來,提供下列詳細資料:

    • 指出您正在建立新的資料庫,還是使用現有的帳戶。 如果您要在資料庫層級佈建輸送量,請選取 [佈建資料庫輸送量] 選項。
    • 輸入集合識別碼。
    • 輸入分割區索引鍵值,(例如 ItemID)。
    • 輸入您要佈建的輸送量 (例如 1000 RU)。
    • 選取 [確定]。

    建立具有資料庫層級輸送量的新集合時,數據總管的螢幕快照

注意

如果您要在設定 Azure Cosmos DB for MongoDB 的 Azure Cosmos DB 帳戶中的容器上佈建輸送量,請使用 myShardKey 來取得分割區索引鍵路徑。

.NET SDK

// refer to MongoDB .NET Driver
// https://docs.mongodb.com/drivers/csharp

// Create a new Client
String mongoConnectionString = "mongodb://DB AccountName:Password@DB AccountName.documents.azure.com:10255/?ssl=true&replicaSet=globaldb";
mongoUrl = new MongoUrl(mongoConnectionString);
mongoClientSettings = MongoClientSettings.FromUrl(mongoUrl);
mongoClient = new MongoClient(mongoClientSettings);

// Change the database name
mongoDatabase = mongoClient.GetDatabase("testdb");

// Change the collection name, throughput value then update via MongoDB extension commands
// https://learn.microsoft.com/azure/cosmos-db/mongodb-custom-commands#update-collection

var result = mongoDatabase.RunCommand<BsonDocument>(@"{customAction: ""UpdateCollection"", collection: ""testcollection"", offerThroughput: 400}");

Azure Resource Manager

您可以使用 Azure Resource Manager 範本,在資料庫或容器層級資源上為所有 Azure Cosmos DB API 佈建自動調整輸送量。 如需範例,請參閱適用於 Azure Cosmos DB 的 Azure Resource Manager 範本

Azure CLI

您可以使用 Azure CLI,在資料庫或容器層級資源上為所有 Azure Cosmos DB API 佈建自動調整輸送量。 如需範例,請參閱適用於 Azure Cosmos DB 的 Azure CLI 範例

Azure PowerShell

您可以使用 Azure PowerShell,在資料庫或容器層級資源上為所有 Azure Cosmos DB API 佈建自動調整輸送量。 如需範例,請參閱適用於 Azure Cosmos DB 的 Azure PowerShell 範例

下一步

請參閱下列文章,以了解 Azure Cosmos DB 中的輸送量佈建: