在 Azure Cosmos DB 中的数据库上预配标准(手动)吞吐量Provision standard (manual) throughput on a database in Azure Cosmos DB

本文说明了如何在 Azure Cosmos DB 的数据库中预配标准吞吐量。This article explains how to provision standard (manual) throughput on a database in Azure Cosmos DB. 可以为单个容器预配吞吐量,也可以为数据库预配吞吐量,并在数据库中的容器之间共享吞吐量。You can provision throughput for a single container, or for a database and share the throughput among the containers within it. 若要了解何时使用容器级别和数据库级别吞吐量,请参阅容器和数据库预配吞吐量的用例一文。To learn when to use container level and database level throughput, see the Use cases for provisioning throughput on containers and databases article. 可以使用 Azure 门户或 Azure Cosmos DB SDK 来预配数据库级别吞吐量。You can provision database level throughput by using the Azure portal or Azure Cosmos DB SDKs.

使用 Azure 门户预配吞吐量Provision throughput using Azure portal

SQL(核心)APISQL (Core) API

  1. 登录 Azure 门户Sign in to the Azure portal.

  2. 创建新的 Azure Cosmos 帐户,或选择现有的 Azure Cosmos 帐户。Create a new Azure Cosmos account, or select an existing Azure Cosmos account.

  3. 打开“数据资源管理器”窗格,然后选择“新建数据库” 。Open the Data Explorer pane, and select New Database. 提供以下详细信息:Provide the following details:

    • 输入数据库 ID。Enter a database ID.
    • 选择“预配吞吐量”。Select Provision throughput.
    • 输入吞吐量(例如 1000 RU)。Enter a throughput (for example, 1000 RUs).
    • 选择“确定”。Select OK.

    “新建数据库”对话框屏幕截图

使用 Azure CLI 或 PowerShell 预配吞吐量Provision throughput using Azure CLI or PowerShell

若要创建具有共享吞吐量的数据库,请参阅To create a database with shared throughput see,

使用 .NET SDK 预配吞吐量Provision throughput using .NET SDK

备注

使用适用于 SQL API 的 Cosmos SDK 为所有 API 预配吞吐量。You can use Cosmos SDKs for SQL API to provision throughput for all APIs. 也可以选择将以下示例用于 Cassandra API。You can optionally use the following example for Cassandra API as well.

所有 APIAll APIs

//set the throughput for the database
RequestOptions options = new RequestOptions
{
    OfferThroughput = 500
};

//create the database
await client.CreateDatabaseIfNotExistsAsync(
    new Database {Id = databaseName},  
    options);

Cassandra APICassandra API

类似命令可以通过任何符合 CQL 标准的驱动程序执行。Similar command can be executed through any CQL compliant driver.

// Create a Cassandra keyspace and provision throughput of 400 RU/s
session.Execute("CREATE KEYSPACE IF NOT EXISTS myKeySpace WITH cosmosdb_provisioned_throughput=400");

后续步骤Next steps

请参阅以下文章,了解在 Azure Cosmos DB 中预配的吞吐量:See the following articles to learn about provisioned throughput in Azure Cosmos DB: