Edit

Share via


Create a container in Azure Cosmos DB for Gremlin

APPLIES TO: Gremlin

This article explains the different ways to create a container in Azure Cosmos DB for Gremlin. It shows how to create a container using Azure portal, Azure CLI, PowerShell, or supported software development kits (SDKs). This article demonstrates how to create a container, specify the partition key, and provision throughput.

This article explains the different ways to create a container in Azure Cosmos DB for Gremlin. If you're using a different API, see API for MongoDB, API for Cassandra, API for Table, and API for NoSQL articles to create the container.

Note

When creating containers, make sure you don’t create two containers with the same name but different casing. That’s because some parts of the Azure platform aren't case-sensitive, and this can result in confusion/collision of telemetry and actions on containers with such names.

Create using Azure portal

  1. Sign in to the Azure portal.

  2. Create a new Azure Cosmos DB account, or select an existing account.

  3. Open the Data Explorer pane, and select New Graph. Next, provide the following details:

    • Indicate whether you're creating a new database, or using an existing one.
    • Enter a Graph ID.
    • Select Unlimited storage capacity.
    • Enter a partition key for vertices.
    • Enter a throughput to be provisioned (for example, 1000 RUs).
    • Select OK.

    Screenshot of API for Gremlin, Add Graph dialog box

Create using .NET SDK

If you encounter timeout exception when creating a collection, do a read operation to validate if the collection was created successfully. The read operation throws an exception until the collection create operation is successful. For the list of status codes supported by the create operation see the HTTP Status Codes for Azure Cosmos DB article.

// Create a container with a partition key and provision 1000 RU/s throughput.
DocumentCollection myCollection = new DocumentCollection();
myCollection.Id = "myContainerName";
myCollection.PartitionKey.Paths.Add("/myPartitionKey");

await client.CreateDocumentCollectionAsync(
    UriFactory.CreateDatabaseUri("myDatabaseName"),
    myCollection,
    new RequestOptions { OfferThroughput = 1000 });

Next steps