Introduction to Cosmos DB
Introduction to Using Cosmos DB
Introduction to Creating an App with Cosmos DB
The course is part of these learning pathsSee 3 more
Cosmos DB is one of many database solutions in a crowded market. From DynamoDB to Cassandra to CockroachDB, the questions one would naturally ask when examining Cosmos DB are, “what makes it special and how can I get started with it?”
This course answers both of those questions as thoroughly and concisely as possible. This course is for anyone with an interest in database technologies or creating software using Microsoft Azure. Whether you are a DevOps engineer, a database admin, a product manager, or a sales expert, this course will help you learn how to power your technology with one of Azure's most innovative data solutions.
From this course, you will learn how to make use of Cosmos DB's incredible flexibility and performance. This course is made up of 9 comprehensive lectures to guide you from the basics to how to create your own app using Cosmos DB.
- Learn the basic components of Cosmos DB
- Learn how to use Cosmos DB via the web portal, libraries, and CLI tools
- Learn how to create an application with Cosmos DB as the data backend
- People looking to build applications using Microsoft Azure
- People interested in database technologies
- General knowledge of IT architecture
- General knowledge of databases
Okay, so now in this next demonstration, we're gonna go through the process of setting up an Azure Cosmos DB account. Now that we have a new event hub, namespace, and event hub, we need a backend to save data. And in the final section, we'll do. In the section after this, we'll talk about Azure functions, something to actually process data.
So we have here a sample account, bethune. Now I'll walk through the steps of how we created it. Similarly, we can do the Create a Resource wizard if we want, and we can just search for Cosmos DB. And so we click on create, and again, we just go, to the fill in the information. We're gonna go through the same resource group we just created before, bethune2, we'll say pay as you go and a name for the account. Let's just keep it as bethune2.
API, this is very important. As you know, Cosmos DB can support many different data structures and API types. So we can do Cassandra. We can do Gremlin. We're going to just stick with the SQL for this demo. We'll keep it, keep it simple.
We'll do the provision throughput capacity mode here. There's a serverless version in preview mode as of this recording but we'll stick with the provision for the location. Let's keep it in the same place as our event, hub US East. And then there's some additional configuration options here. We don't really need any of this stuff. Multi-region geo-redundancy. This is, if you want a greater, greater resilience and more robust deployment, we don't really need to worry about this stuff.
So review and create, and as before it'll do a validation first. So it's valid. There's nothing wrong with this config. We then click create, and this will just take a moment to deploy. So the account is in progress and it's important to remember once this is done, you don't have a database yet. You just have the account. So you have to actually create the actual schema, the collections and, you know, DB instances manually, or you can actually have your software created. You can have an Azure function, or you could submit a SQL query. There's many ways to, to create the schema afterward, but here we can see a deployment is in progress.
Usually only takes about a minute or so, and we can see, well, if we click refresh, we'll see if it's making any progress. Alright, well, let's, let's give this a sec. We'll come back when this is done.
Okay. So it took a few minutes longer than I thought, but it did eventually complete. We have here our Azure Cosmos DB bethune2 account, which successfully finished. So what we can do is now actually look at the data, although there's no data there, I'll, I'm gonna show you how we can create a database, which will be our, our storage for our application.
So there's the bethune1 here, which was done for test purposes. This is bethune2 account that we just created. Now, if we go into it, there's nothing there right now. So to create a database within the account, there's a lot of ways you can do that. You can get with the API, you can get with it with the query. We're going to go through the Data Explorer piece here. And in this window, you can see, they give us a few options. You can create a container, which is a sort of a fixed storage and then throughput unit. Or you can go through here to create the database directly, which will give us our initial schema. And remember, this is all SQL API.
So what we'll do is we'll, we'll just create a database to start. We'll give it a unique ID to call it. We'll call it the database bethunetest, just to give it a slightly different name. You know, the, the throughput is fine. We can pick the default. We don't really need to worry about scaling or anything right now. So we'll just click okay for that. And in a few seconds we should have our database backend. Good to go. Fetching. Okay. There it is.
Now that's coming up and we can see there's no data in there. Now, if we go to this older one that does have data, we can see what it would look like. What, what we should hope to get. This one, bethune, has working data in it. I believe it's under the bethune1 collection. Yeah, here we go.
So you can see here items. If you do have data, you'll see, you know, a separate collection and you'll see some items that will load. So this one has one unit there and this one, oh, this one actually has more of than this one under Bethune has more items, these message items here. So we'll know that we've succeeded with our app. When we can go back to this one here that we just created, bethune2, and we should see a collection and items.
So in order to do that, we need to create an answer function, to process some data. And then we're going to send some messages that will be captured by the event hub processed by the function and stored in our Cosmos DB backend. So next up is, Azure function, see you there.
Jonathan Bethune is a senior technical consultant working with several companies including TopTal, BCG, and Instaclustr. He is an experienced devops specialist, data engineer, and software developer. Jonathan has spent years mastering the art of system automation with a variety of different cloud providers and tools. Before he became an engineer, Jonathan was a musician and teacher in New York City. Jonathan is based in Tokyo where he continues to work in technology and write for various publications in his free time.