在 Azure Cosmos DB Cassandra API 资源上预配数据库、容器或自动缩放吞吐量Provision database, container or autoscale throughput on Azure Cosmos DB Cassandra API resources

适用于: Cassandra API

本文介绍如何在 Azure Cosmos DB Cassandra API 中预配吞吐量。This article explains how to provision throughput in Azure Cosmos DB Cassandra API. 你可在一个容器或数据库上预配标准(手动)或自动缩放吞吐量,并在数据库中的容器之间共享。You can provision standard(manual) or autoscale throughput on a container, or a database and share it among the containers within the database. 你可使用 Azure 门户、Azure CLI 或 Azure Cosmos DB SDK 来预配吞吐量。You can provision throughput using Azure portal, Azure CLI, or Azure Cosmos DB SDKs.

如果你使用的是其他 API,请参阅 SQL API适用于 MongoDB 的 APIGremlin API 文章来预配置吞吐量。If you are using a different API, see SQL API, API for MongoDB, Gremlin API articles to provision the throughput.

Azure 门户Azure portal

  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 Table. 接下来,请提供以下详细信息:Next, provide the following details:

    • 指出要创建新密钥空间还是使用现有密钥空间。Indicate whether you are creating a new keyspace or using an existing one. 如果要在密钥空间级别预配吞吐量,请选择“预配数据库吞吐量”选项。Select the Provision database throughput option if you want to provision throughput at the keyspace level.
    • 在 CQL 命令中输入表 ID。Enter the table ID within the CQL command.
    • 输入主键值(例如 /userrID)。Enter a primary key value (for example, /userrID).
    • 输入要预配的吞吐量(例如,1000 RU)Enter a throughput that you want to provision (for example, 1000 RUs).
    • 选择“确定”。Select OK.

    创建具有数据库级吞吐量的新集合时的数据资源管理器的屏幕截图

备注

若要使用 Cassandra API 在 Azure Cosmos DB 帐户中为容器预配吞吐量,请使用 /myPrimaryKey 作为分区键路径。If you are provisioning throughput on a container in an Azure Cosmos account configured with Cassandra API, use /myPrimaryKey for the partition key path.

.NET SDK.NET SDK

为 Cassandra 表预配吞吐量Provision throughput for a Cassandra table

// Create a Cassandra table with a partition (primary) key and provision throughput of 400 RU/s
session.Execute("CREATE TABLE myKeySpace.myTable(
    user_id int PRIMARY KEY,
    firstName text,
    lastName text) WITH cosmosdb_provisioned_throughput=400");

类似的命令可以通过任何 CQL 兼容的驱动程序发出。Similar commands can be issued through any CQL-compliant driver.

修改或更改 Cassandra 表的吞吐量Alter or change throughput for a Cassandra table

// Altering the throughput too can be done through code by issuing following command
session.Execute("ALTER TABLE myKeySpace.myTable WITH cosmosdb_provisioned_throughput=5000");

类似命令可以通过任何符合 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");

Azure 资源管理器Azure Resource Manager

Azure 资源管理器模板可用于在数据库或容器级资源上为所有 Azure Cosmos DB API 预配自动缩放吞吐量。Azure Resource Manager templates can be used to provision autoscale throughput on database or container-level resources for all Azure Cosmos DB APIs. 有关示例,请参阅 Azure Cosmos DB 的 Azure 资源管理器模板See Azure Resource Manager templates for Azure Cosmos DB for samples.

Azure CLIAzure CLI

Azure CLI 可用于在数据库或容器级资源上为所有 Azure Cosmos DB API 预配自动缩放吞吐量。Azure CLI can be used to provision autoscale throughput on a database or container-level resources for all Azure Cosmos DB APIs. 有关示例,请参阅用于 Azure Cosmos DB 的 Azure CLI 示例For samples see Azure CLI Samples for Azure Cosmos DB.

Azure PowerShellAzure PowerShell

Azure PowerShell 可用于在数据库或容器级资源上为所有 Azure Cosmos DB API 预配自动缩放吞吐量。Azure PowerShell can be used to provision autoscale throughput on a database or container-level resources for all Azure Cosmos DB APIs. 有关示例,请参阅适用于 Azure Cosmos DB 的 Azure PowerShell 示例For samples see Azure PowerShell samples for Azure Cosmos DB.

后续步骤Next steps

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