在 Azure Cosmos DB 容器上佈建標準 (手動) 輸送量 - 適用於 NoSQL 的 API

適用於:NoSQL

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

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

Azure 入口網站

  1. 登入 Azure 入口網站

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

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

    • 指出您正在建立新的資料庫,還是使用現有的帳戶。
    • 輸入 [容器識別碼]
    • 輸入 [分割區索引鍵] 值 (例如 /ItemID)。
    • 選取 [自動調整] 或 [手動] 輸送量,然後輸入所需的 [容器輸送量] (例如,1000 RU/秒)。 輸入您要佈建的輸送量 (例如 1000 RU)。
    • 選取 [確定]。

    Screenshot of Data Explorer, with New Collection highlighted

Azure CLI 或 PowerShell

若要建立具有專用輸送量的容器,請參閱

.NET SDK

注意

使用適用於 NoSQL API 的 Azure Cosmos DB SDK,來為所有 Azure Cosmos DB API 佈建輸送量,但 Cassandra 和適用於 MongoDB 的 API 除外。

// Create a container with a partition key and provision throughput of 400 RU/s
DocumentCollection myCollection = new DocumentCollection();
myCollection.Id = "myContainerName";
myCollection.PartitionKey.Paths.Add("/myPartitionKey");

await client.CreateDocumentCollectionAsync(
    UriFactory.CreateDatabaseUri("myDatabaseName"),
    myCollection,
    new RequestOptions { OfferThroughput = 400 });

JavaScript SDK

// Create a new Client
const client = new CosmosClient({ endpoint, key });

// Create a database
const { database } = await client.databases.createIfNotExists({ id: "databaseId" });

// Create a container with the specified throughput
const { resource } = await database.containers.createIfNotExists({
id: "containerId",
throughput: 1000
});

// To update an existing container or databases throughput, you need to user the offers API
// Get all the offers
const { resources: offers } = await client.offers.readAll().fetchAll();

// Find the offer associated with your container or the database
const offer = offers.find((_offer) => _offer.offerResourceId === resource._rid);

// Change the throughput value
offer.content.offerThroughput = 2000;

// Replace the offer.
await client.offer(offer.id).replace(offer);

下一步

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