Kick Start With Azure Cosmos DB - Part Two

In this article, we will learn how to create a new Azure Cosmos DB for free. How can we use it for free? I have found a couple of alternative ways to use the Azure Cosmos DB for free without an Azure Subscription. It's a good thing no credit card details are required. I hope you have read my previous article. If not, then you can go and read my previous article here. The first way is, you can create a new Azure Cosmos DB free of cost without a credit card number. The second way is, you can use the Azure Cosmos DB Emulator for the development purposes in your laptop.

In this article, we will see the following,

  • How to create a new Azure Cosmos DB for free
  • How to install the Azure Cosmos DB Emulator
  • How to start the Azure Cosmos DB Emulator
  • How to create a new database and collection using Azure Cosmos DB Emulator

Prerequisite

  • Azure Cosmos DB for free
  • Azure Cosmos DB Emulator

How to create a new Azure Cosmos DB for free

You will learn in this section, how to create a new Azure Cosmos DB account using the Azure portal.

  • Go to open the new browser, you can copy and paste the following URL.
    https://azure.microsoft.com/en-us/try/cosmosdb/
  • Then, choose the database server and click the "Create" button.
 

Now, you have to authenticate using Microsoft account credentials as in the following screenshot.

 

After successfully authenticating to the Microsoft account, the following screen will appear. Click "Open in the Azure portal" button as in the below screenshot.

 

After the Azure Cosmos DB account is created successfully, a "Congratulations! Your Azure Cosmos DB account was created" window will be opened.

 

Note you can see highlighted account expiry information for the above screen. The free account will expire on 06d:22h:00min. if you want more for free? You have to sign up for Azure Free Trial or extend the current account.

How to install the Azure Cosmos DB Emulator

You will learn in this section, how to install the Azure Cosmos DB Emulator in the local environment and system requirements.

The following software and hardware are required.

  • Windows Server 2016, Windows Server 2012 R2, Windows 10
  • 2 GB Ram
  • 10 GB free space for HDD

Now, you can download the Azure Cosmos DB Emulator from the following URL.

  • https://aka.ms/cosmosdb-emulator

Double-click the Azure Cosmos DB.Emulator.msi file.

 
The Azure Cosmos DB Emulator setup window will be opened.
 

The Azure Cosmos DB Emulator License Agreement window will have opened, you can check the terms of the license agreement and click the Install button.

 

You can see that the installation process has started now.

 

After successfully installing Azure Cosmos DB Emulator, click the "Finish" button.

 

Now, you can get the notification for starting Azure Cosmos DB Emulator service in taskbar area. Also, you can find the icon in the Windows notification tray.

 
 
 

After the Azure Cosmos DB account is started, the "Congratulations! Your Azure Cosmos DB emulator is running" window will be opened in the following screenshot.

  • https://localhost:8081/_explorer/index.html
 

How to start the Azure Cosmos DB Emulator

You can learn in this section, how to star the Azure Cosmos DB Emulator on your laptop.

You can go to Start button >> Type Azure Cosmos DB Emulator in the Search Box, then you can see the Azure Cosmos DB Emulator desktop app. Click the Azure Cosmos DB Emulator,

 

Now, you can get the notification for starting Azure Cosmos DB Emulator service in the taskbar area. Also, you can find the icon in the Windows notification tray.

 

After the Azure Cosmos DB account has started, the "Congratulations! Your Azure Cosmos DB emulator is running" window will be opened in the following screenshot.

  • https://localhost:8081/_explorer/index.html
 

How to create a new database and collection using Azure Cosmos DB Emulator

You can learn in this section, how to create a new database and collection in Explorer using Azure Cosmos DB Emulator at the following guidelines.

You can go to Explorer - click the New Collections.

 

The "Add Collection" window will open and you can enter the following details as required for the screenshots. Then, click the OK button.

  • Database Id
  • Collection Id
  • Storage Capacity
  • Throughput
 

You can see that the new database and collection looks like in the following screenshot.

 

How to add data to the collection using Explorer

You will learn in this section, how to add sample data to the collection in Explorer using Azure Cosmos DB Emulator in the local environment.

You can go to Explorer - Expand the TableBooking collection in the Collection window, click the Documents - click the New Document.

 

The new document window will open and add the data to the collection with the following format.

 

Once you have added JSON data to the document, click the Save button.

 

After you have successfully added records to the collection it looks like the following screenshot.

 

Reference

  • https://docs.microsoft.com/en-us/azure/cosmos-db/local-emulator
  • http://san2debug.net/post/kick-start-with-azure-cosmos-db-part-2.aspx
Conclusion

I hope you understand now about Azure Cosmos DB, how to create a new Azure Cosmos DB for free, how to install the Azure Cosmos DB Emulator, how to start the Azure Cosmos DB Emulator, how to create a new database and how to create collect using Azure Cosmos DB Emulator. I have covered all the required things. If you find anything missing, please let me know.

Please share your valuable comments or feedback to improve my future articles.


Similar Articles