Standaarddoorvoer (handmatig) inrichten voor een Azure Cosmos DB-container - API voor NoSQL

VAN TOEPASSING OP: NoSQL

In dit artikel wordt uitgelegd hoe u standaarddoorvoer (handmatig) inricht voor een container in Azure Cosmos DB voor NoSQL. U kunt doorvoer inrichten voor één container of doorvoer inrichten voor een database en deze delen tussen de containers in de database. U kunt doorvoer inrichten voor een container met behulp van Azure Portal, Azure CLI of Azure Cosmos DB SDK's.

Als u een andere API gebruikt, raadpleegt u API voor MongoDB, API voor Cassandra, API voor Gremlin-artikelen om de doorvoer in te richten.

Azure Portal

  1. Meld u aan bij de Azure-portal.

  2. Maak een nieuw Azure Cosmos DB-account of selecteer een bestaand Azure Cosmos DB-account.

  3. Open het deelvenster Data Explorer en selecteer Nieuwe container. Geef de volgende gegevens op:

    • Geef aan of u een nieuwe database maakt of een bestaande database gebruikt.
    • Voer een container-id in.
    • Voer een partitiesleutelwaarde in (bijvoorbeeld /ItemID).
    • Selecteer Automatisch schalen of Handmatige doorvoer en voer de vereiste containerdoorvoer in (bijvoorbeeld 1000 RU/s). Voer een doorvoer in die u wilt inrichten (bijvoorbeeld 1000 RU's).
    • Selecteer OK.

    Screenshot of Data Explorer, with New Collection highlighted

Azure CLI of PowerShell

Als u een container met toegewezen doorvoer wilt maken, raadpleegt u

.NET SDK

Notitie

Gebruik de Azure Cosmos DB SDK's voor API voor NoSQL om doorvoer in te richten voor alle Azure Cosmos DB-API's, met uitzondering van Cassandra en API voor 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);

Volgende stappen

Zie de volgende artikelen voor meer informatie over het inrichten van doorvoer in Azure Cosmos DB: