Your guide to getting started with Microsoft's globally distributed, multi-model database service.
Azure Cosmos DB is a globally distributed, multi-model database service that enables you to harness the benefits of global distribution with minimal effort. It supports various data models, including document, key-value, graph, and column-family, and offers robust APIs to interact with your data.
This guide will walk you through the essential steps to create your first Azure Cosmos DB account, container, and item, setting you up for success with this powerful database solution.
Navigate to the Azure portal. Search for "Azure Cosmos DB" and select it. Click "Create".
Choose your desired API (e.g., Core (SQL) API for document data). Fill in the required fields, including subscription, resource group, account name, region, and capacity mode.
Review and create your account. This process typically takes a few minutes.
For a Core (SQL) API account, you can use the following sample data structure for your initial item:
{
"id": "example-item-1",
"category": "example",
"name": "My First Cosmos DB Item",
"description": "This is a sample document stored in Azure Cosmos DB.",
"tags": ["sample", "getting-started", "cosmosdb"]
}
Once your Cosmos DB account is deployed, navigate to its resource page in the Azure portal.
Under "Data Explorer", select "New Container".
Choose or create a database. Enter a container ID (e.g., my-container) and specify a partition key (e.g., /category if using the sample data above). The partition key is crucial for performance and scalability.
Within the newly created container in Data Explorer, select "Items" and then "New Item".
Paste the sample JSON data provided earlier (or your own custom data) into the editor.
Click "Save". You should now see your item listed in the container.
In Data Explorer, you can view, query, and manage your items directly. Try running a simple query like:
SELECT * FROM c
To see all items in the container.
Congratulations! You've successfully set up your first Azure Cosmos DB instance and added data. Here are some recommended next steps: