Quickstart: Create an Azure Cosmos DB account and database
This quickstart guides you through the process of creating an Azure Cosmos DB account, database, and container using the Azure portal.
Prerequisites
Before you begin, you need an Azure subscription. If you don't have one, create a free account.
You can also use an existing Azure account.
Step 1: Create an Azure Cosmos DB account
Sign in to the Azure portal.
In the Azure portal, search for and select Azure Cosmos DB.
On the Azure Cosmos DB page, select Create.
On the Create Azure Cosmos DB page, fill in the following details:
- Subscription: Select your Azure subscription.
- Resource group: Select an existing resource group or create a new one (e.g.,
myResourceGroup). - Account name: Enter a globally unique name for your Azure Cosmos DB account (e.g.,
mycosmosdbaccount123). - API: Choose Core (SQL). This is the default API and most common for new applications.
- Location: Select an Azure region close to your users.
Select Review + create, and then select Create.
Account creation can take a few minutes.
Step 2: Create a database and container
Once the deployment is complete, navigate to your Azure Cosmos DB account resource in the Azure portal.
In the left navigation pane of your Azure Cosmos DB account, select Data Explorer.
In Data Explorer, select New Container.
The New Container pane opens on the right.
Fill in the New Container details:
- Database ID: Select Create new and enter a name for your database (e.g.,
ToDoList). - Container ID: Enter a name for your container (e.g.,
Items). - Partition key: Enter
/category. A partition key is required for distributing data across logical partitions. - Throughput: Leave the default (Manual, 400 RU/s) or choose Autoscale for dynamic scaling.
Select OK to create the database and container.
Step 3: Add sample data
In Data Explorer, expand the ToDoList database and select the Items container.
Select New Item.
Paste the following JSON into the item editor:
{
"id": "1",
"category": "personal",
"name": "groceries",
"description": "Buy milk and eggs",
"isComplete": false
}
Select Save.
Repeat steps 2-4 to add another item:
{
"id": "2",
"category": "work",
"name": "project proposal",
"description": "Finalize and submit the proposal",
"isComplete": false
}
Next Steps
You have successfully created an Azure Cosmos DB account, database, and container, and added sample data. Now you can:
- Learn more about Azure Cosmos DB concepts.
- Explore the supported APIs.
- Use the Azure Cosmos DB SDKs to interact with your data programmatically.
- Follow the tutorials to build a web application.