Menyediakan throughput standar (manual) pada kontainer Azure Cosmos DB - API untuk NoSQL

BERLAKU UNTUK: NoSQL

Artikel ini menjelaskan cara menyediakan throughput standar (manual) pada kontainer di Azure Cosmos DB untuk NoSQL. Anda dapat memprovisikan throughput pada kontainer tunggal, atau menyediakan throughput pada database dan membagikannya antara kontainer dalam database. Anda dapat memprovisikan throughput dengan menggunakan kontainer portal Microsoft Azure, Azure CLI, atau SDK Microsoft Azure Cosmos DB.

Jika Anda menggunakan API yang berbeda, lihat artikel API untuk MongoDB, API untuk Cassandra, API untuk Gremlin untuk menyediakan throughput.

Portal Azure

  1. Masuk ke portal Azure.

  2. Buat akun Azure Cosmos DB baru, atau pilih akun Azure Cosmos DB yang sudah ada.

  3. Buka panel Azure Data Explorer, dan pilih Kontainer Baru. Selanjutnya, harap berikan detail berikut:

    • Menunjukkan apakah Anda membuat database baru atau menggunakan database yang sudah ada.
    • Masukkan ID Kontainer.
    • Masukkan nilai kunci Partisi (misalnya, /ItemID).
    • Pilih throughput Autoscale atau Manual dan masukkan throughput Kontainer yang diperlukan (misalnya, 1000 RU/dtk). Masukkan throughput yang ingin Anda provisikan (misalnya, 1000 RU).
    • Pilih OK.

    Screenshot of Data Explorer, with New Collection highlighted

Azure CLI atau PowerShell

Untuk membuat kontainer dengan throughput khusus lihat,

.NET SDK

Catatan

Gunakan SDK Azure Cosmos DB untuk API untuk NoSQL untuk menyediakan throughput untuk semua API Azure Cosmos DB, kecuali Cassandra dan API untuk MongoDB.

// 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);

Langkah berikutnya

Lihat artikel berikut untuk mempelajari provisi throughput di Microsoft Azure Cosmos DB: