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 1 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
So assuming you have your event hub ready to go, and you're kind of comfortable with your Azure account, what you need is your Cosmos DB backend. This will be where we store our data. This will be the main part of our sample test, sort of test application here. And this is probably, if not the second easiest, the easiest thing to do, because in the portal setting up a Cosmos DB account is literally just a few clicks. So all we do is, we can actually just click on Cosmos DB. You can go through Create a resource, but we can just click on Cosmos DB, and what we're gonna do is create an Azure Cosmos DB account, all right?
So we can just start from there and it'll take us through the wizard to set it up. So you set an account ID and let's type in, put in my last name for that. We select an API. We're gonna go with the SQL API because it's a little bit more plug and play, a little easier. You can use other APIs of course, within that hub and with Azure functions. But we're gonna use that for a resource group. This account, we already defined a resource group. I'm just using my last name Bethune. You can do that on your own. The name doesn't really matter. Location, we're gonna keep central US 'cause that's where our event hub is. Easiest way to do things. There are some other settings here we don't really need to worry about. We don't need multi master, we don't need any of the preview stuff there. So once you have that you just click create and in a matter of seconds you've got your Cosmos DB account ready to go. Now we're gonna let that create. Once that's done what we're gonna have to do, so you can see here it says deployment in progress.
It takes a second for them to kind of spit it up on the backend. But once that's done what we're gonna do is we're gonna create actually the database, and we're going to create our first collection. So once you have your, once the account is finished creating, and it might take a couple of minutes actually. It's not gonna necessarily be instant. Once it's created, creating the database and the collection is pretty straightforward. Just click on your account and your set of resources, and then from there you can go to add collection or you can go through Data Explorer. I'm gonna go through Data Explorer because it's a little bit, well we've talked about Data Explorer in the earlier parts of the class. So this UI is a little bit more intuitive. You have your account set for SQL API. We wanna create a new database. So we're gonna go ahead and do that. And then when you create your new database it only needs a few bits of information. It needs a database ID or name basically. We're gonna call it TestappDB with caps there. We don't need to do provision throughput. That's not something we need to worry about. And then we'll click OK. That'll take a second to deploy.
It's pretty much instant. And then we're gonna create our first collection within that database. So we can click New Collection. And this will require a little bit of info. It's gonna require name. We're gonna call it TestCollection. And then capacity. Now you can set it to unlimited and it'll just grow as you need. For our purposes we're gonna do fixed. You can also set request units. It's gonna ask for a value here. The minimum that it suggests here is 400. So we'll put it at 400 request units. This is really just for testing, so we don't need more than that. And then there's a unique key. This is important for more complex schemas. For this basic test we don't need to worry about it, so we'll just click OK. And then, again, pretty much instantly we will have our collection. So congrats, we now have a Cosmos DB account set up, we have our API selected, we have a database created, and we have our first collection, awesome.
About the Author
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.