Step-by-Step Tutorial: Creating Your First Azure Cosmos DB Database

Step-by-Step Tutorial: Creating Your First Azure Cosmos DB Database


Azure Cosmos DB is a fully managed NoSQL database service that offers global distribution, high availability, and low latency. It supports multiple data models, making it suitable for a wide range of applications. In this tutorial, we will guide you through the process of creating your first Azure Cosmos DB database. By the end of this tutorial, you’ll have a fully functional Cosmos DB database up and running, ready to store and manage your data.


Before we begin, make sure you have the following prerequisites in place:

  1. An active Azure account: If you don’t have one, you can sign up for a free trial at
  2. Basic knowledge of Azure Portal: Familiarity with the Azure Portal will be helpful, but this tutorial will provide step-by-step instructions.

Step 1: Log in to the Azure Portal

  1. Open your web browser and navigate to the Azure Portal at
  2. Sign in with your Azure account credentials.

Step 2: Create a new Cosmos DB account

  1. Once you are logged in, click on “+ Create a resource” from the left-hand menu.
  2. In the “New” search box, type “Cosmos DB” and select “Azure Cosmos DB” from the results.
  3. Click the “Create” button to start creating a new Cosmos DB account.

Step 3: Configure the Cosmos DB account

  1. In the “Basics” tab, choose your subscription and create a new resource group or select an existing one.
  2. Enter a unique name for your Cosmos DB account. This name will be used as the URL for accessing your database.
  3. Select the API you want to use. For this tutorial, we’ll choose “Core (SQL)” for a document database.
  4. Choose a preferred location where you want your data to be stored. You can add more locations later for global distribution.
  5. Leave the “Geo-redundancy” option as “Disabled” for this tutorial. You can enable it for data replication across regions.

Step 4: Configure advanced settings (Optional)

  1. You can skip this step for now and proceed with the default settings. Advanced configurations can be done later based on your requirements.

Step 5: Review and create the Cosmos DB account

  1. Double-check the configurations you have provided in the previous steps.
  2. Click the “Create” button to create your Azure Cosmos DB account. The deployment may take a few minutes.

Step 6: Access your Cosmos DB account

  1. Once the deployment is complete, navigate to your newly created Cosmos DB account from the Azure Portal.
  2. In the overview section, you’ll find essential details like the URL, primary key, and API type.

Step 7: Create a new database and container

  1. In the Cosmos DB account, click on the “Data Explorer” tab from the left-hand menu.
  2. Click on “New Container” to create a new database and container.
  3. Enter a unique ID for your database and container. Choose the partition key, throughput, and other settings as per your application requirements.

Step 8: Insert data into your container

  1. With the container created, click on the “Items” tab to start inserting data.
  2. Click on “New Item” and provide JSON data to insert into your container.


Congratulations! You have successfully created your first Azure Cosmos DB database. In this tutorial, we walked through the step-by-step process of setting up an Azure Cosmos DB account, creating a database, and inserting data into it. Azure Cosmos DB’s scalability, global distribution, and flexible data models make it an excellent choice for modern applications. As you continue to explore Azure Cosmos DB, you can explore additional features such as global distribution, custom indexing, and scaling to meet your application’s specific needs. Happy coding!