Effettuare il provisioning della velocità effettiva standard (manuale) per un contenitore in Azure Cosmos DB - API per NoSQL

SI APPLICA A: NoSQL

Questo articolo illustra come effettuare il provisioning della velocità effettiva standard (manuale) in un contenitore in Azure Cosmos DB per NoSQL. È possibile effettuare il provisioning della velocità effettiva per un singolo contenitore oppure effettuare il provisioning della velocità effettiva per un database e condividerlo tra i contenitori all'interno del database. Il provisioning della velocità effettiva per un contenitore può essere effettuato usando il portale di Azure, l'interfaccia della riga di comando di Azure o gli SDK di Azure Cosmos DB.

Se si usa un'API diversa, vedere gli articoli API per MongoDB, API per Cassandra e API per Gremlin per effettuare il provisioning della velocità effettiva.

Azure portal

  1. Accedere al portale di Azure.

  2. Creare un nuovo account Azure Cosmos DB o selezionare un account di Azure Cosmos DB esistente.

  3. Aprire il riquadro Esplora dati e selezionare Nuovo contenitore. Specificare quindi i dettagli seguenti:

    • Indicare se si intende creare un nuovo database o usarne uno esistente.
    • Immettere un valore nel campo ID contenitore.
    • Immettere un valore nel campo Chiave partizione (ad esempio, /ItemID).
    • Selezionare Scalabilità automatica o velocità effettiva manuale e immettere la velocità effettiva del contenitore richiesta, ad esempio 1000 UR/sec. Immettere una velocità effettiva di cui si desidera eseguire il provisioning (ad esempio, 1000 UR).
    • Seleziona OK.

    Screenshot of Data Explorer, with New Collection highlighted

Interfaccia della riga di comando di Azure o PowerShell

Per creare un contenitore con una velocità effettiva dedicata, vedere:

.NET SDK

Nota

Usare l'API per NoSQL di Azure Cosmos DB SDK per effettuare il provisioning della velocità effettiva per tutte le API Azure Cosmos DB ad eccezione dell'API Cassandra e 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);

Passaggi successivi

Vedere gli articoli seguenti per informazioni sul provisioning della velocità effettiva in Azure Cosmos DB: