Do you want to create your new Cosmos DB account and first database and collections right from Visual Studio Code? Read this article to learn hands on coding to create database in azure and visualize in Visual Studio Code.
You will learn how to setup your development environment in Visual Studio Code. You will create CosmosDB account, Database & Collections in Visual Studio Code.
In order for learning azure you need access to free resources 🆓 given by Microsoft. This is great help from Microsoft. If you will use Sandbox resources then your personal account will not be charged at all.
This way you can learn Azure quickly without thinking of billing and credit cards 💳. Use this link to Sign in and Activate Sandbox and validate your account.
👍 Go ahead and activate sandbox in your azure account highly recommended! You have to review the permissions and immediately your permissions will be verified and sandbox will be activated in your account.
You will be getting limited time and sandboxes per day.
Here is the link for Azure Database Extension Free extension from Microsoft for Visual Studio Code.
Let’s login and create new Cosmos DB account and visualize it in the visual studio code.
🗽 Log in to Azure using the same account used to create the sandbox. The sandbox provides access to a Concierge Subscription.
Select Concierge Subscription that is free sandbox account. Right click Concierge Subscription , and select Create Server to start creating an Azure Cosmos DB account.
Azure Cosmos DB supports various APIs like:
- Core (SQL) (default) 👈 we will use this
- MongoDB API
- Azure Table
- Gremlin (graph)
In this demo I will select Core (SQL) that allows you to fetch JSON and query like SQL. 🥇
The account name must be globally unique and can contain only lowercase letters, numbers and the ‘-‘ character, and must be between 3 and 31 characters. 👮♂️
We are using free sandbox account and Microsoft has created a special resource group called as learn-5bad6f42-af9e-4e6c-9546-629cb0600e31 you must select this group. 🍇
You will get various locations select the location whichever is closure to your home. 🌐
It took 1 min for me to finish and create my first Cosmos DB account.
Expand your Azure subscription in the Azure: Cosmos DB pane. The extension displays the new Azure Cosmos DB account.
Congratulations 🍕 you created your Azure Db Account from Visual Studio Code.
Now let’s create a new database and collection for your customers. You need below things to create a database:
- ✔️ Database Name
- ✔️ Collection Name (Table)
- ✔️ Partition Key and
- ✔️ Throughput
Follow the below steps to create your first database and collection in Cosmos DB.
In the Azure: Cosmos DB pane, right-click your new account, and then select Create Database. Give sales as your database name and press Enter.
In the input palette at the top of the screen, enter Products for the database name and press Enter.
In my sales database, I will add partition key as productId only and press Enter.
You can keep the default value on the throughput value.
Congratulations you created your first cosmos DB account, new database and collection all in visual studio code.
If you enjoyed this article then please share to your friends and if you have suggestions or thoughts to share with me then please write in the comment box.
- Please subscribe to All-Access Membership PRO plan to access current and future angular, node.js and related courses.
- Please subscribe to All-Access Membership ELITE plan to get everything from PRO plan. Additionally, you will get access to monthly live Q&A video call with
Rupeshand you can ask doubts/questions and get more help, tips and tricks.
Your future is waiting for you so visit today FullstackMaster and allow me to help you to board on your dream software company as a new Software Developer, Architect or Lead Engineer role.