This is the bot series on ToDo Bot where we will be creating a Chatbot to create, view, and delete tasks. In this part, we will be working with the Azure Cosmos DB local emulator to understand basic functionalities before connecting the bot with DB.
The Azure Cosmos DB Emulator provides a local environment that emulates the Azure Cosmos DB service for development purposes. Using the Azure Cosmos DB Emulator, you can develop and test your application locally, without creating an Azure subscription or incurring any costs.
For more information, refer Microsoft Documentation (opens in a new tab).
Prerequisites
Advertisement
Video
Advertisement
Create Database
After installing, open the emulator. It usually runs on localhost:8081. Below is the landing page you get with URI, primary key, and connection strings.

You can learn by choosing a platform and downloading a sample code. We will use the same sample code for .NET Core in our implementation.
You can create the DB using the code, but in this case we will use the UI. Go to the Explorer and click on new database.

Give a name of the DB and click OK. I have given the name as ToDoBotDB.

Advertisement
Create Container
Now, we create a container inside the DB. Click on New Container.

Give a name of the container id and a partition key.

With this, a container gets created. We are now ready to start adding items into the container.

Advertisement
Add Item
Let us now add new items into the container. Click on New Item and add item using the JSON.
{
"id": "C1",
"Task": "call a friend"
}
When you click on save, a new item is added.

Advertisement
Query
We can query the container to get all the items or specific items (using filter) from the container. Click on New Query.

Execute the query already present. This gets all the items.

In the next part, we will connect this DB with Bot Framework.
Thank you All!!! Hope you find this useful.
Advertisement

0 comments