6.2 Cosmos DB Demo

Video Activity
Join over 3 million cybersecurity professionals advancing their career
Sign up with
Required fields are marked with an *

Already have an account? Sign In »

18 hours 43 minutes
Video Transcription
Welcome back. In this episode, we're gonna jump back out to our azure portal and take a look at Cosmos TB in a demo.
The objectives include we're gonna create a cosmos account and then we're gonna go in and configure some of our options like creating databases, containers, uploading some items as well a setting consistency levels and are multi mode regions.
Let's jump out to the azure portal
back in our azure portal. Let's go ahead and click on, Create a resource.
We'll search for Cosmos TV
and go ahead and select on Create.
First, we need to select a resource group.
I already have an existing one called Database Stash RG.
Then we need to enter in some instance details.
First, we need to create an account name and remember it. This does need to be globally unique.
Next, we also need to choose our A p I that we're gonna use to interact with our cosmos TV Instance
we do have a sequel, which is our core a p I,
and has mentioned from the slides we have other ones for mongo, D B, Cassandra as your table or Gremlin. I'm just gonna leave it at sequel For right now
we need to choose our primary location like our other demos. I'm just gonna choose East us.
And to start with, we could enable Jill redundancy or multi region rights. But right now, I'm gonna leave these disabled because I want to enable them inside the cosmos TV account itself after we create it. Let's go and select review and create and create our Cosmos de Bie account.
Now, with our resource deployed that took a couple of minutes. Let's go check it out
when we first jump into our cosmos, account is going to go to a quick start. Or we can choose a platform that will be coding our cosmos TV against and creating items and containers.
But for now, I want to go back to overview and check out some of our properties that we have.
First you'll notice are your I Sigh bury a Z 300 demo that documents dot azure dot com.
This is going to be the your eye we used to access our cosmos d b programmatically from our applications.
Next under settings, let's go to replicate data globally and here is where we can add a remove regions from our Cosmos TB account,
For example. Right now we're in the East US, but I don't want to hear on the map. I could select West us, and it's gonna add it as a reed region over on the right. Or I can click on Add a region over here
and in the drop down menu. Choose another option for our region now. Right now, you'll see we have East us as our only right region and as we ADM or they automatically are added under read regions.
But we do have the option of configuring multi region rights,
and this is going to allow us to take better advantage of our provisions. Third, put by allowing rights to multiple regions which may be closer to our end users.
And if we enable this, we can see all of our regions now become, read and write regions
for this demo, I'm going to go ahead and disable our multi region right
If he also noticed we have a manual fail over option up here as well as automatic fail over so we can fill over our cosmos account to another region
under settings. Let's go check out default consistency.
And here we have our five consistency levels that we talked about inside of our slides.
Let's start back over on the left side with strong
strong is gonna be the most predictable. And we're always gonna make sure we are reading the most recent rights to our data.
And Microsoft includes a neat little animation down here on the right that shows how our reads and writes air Gonna work across regions. Here you can see our East us is the primary for reads and writes. And then we have Japan, ese and West us as our other regions that we have configured
as data is written. It's gonna be consistently red across all the regions at the same time,
so this might lead to a little bit lower, light and see. But we're gonna have more consistent access to the data.
We move over to bounded staleness.
We're going to get low, right, lighten sees.
But when we read the data, we're going to get it back consistently and in the right order.
And as the name indicates, bounded staleness, we have a maximum lag time or maximum operations before we go and get the latest version of the data,
and here in our animation, you can see the East US rights and reads are in sync before our other regions there a little bit slower.
So for our multi region configuration, here we have a maximum delay of 100,000 versions or 300 seconds, whichever is smaller. So we can see trying to read from Japan east or west US is a little bit delayed behind our east US region.
Next, let's check out session
as mentioned in the slides. This is the most widely used option whenever we have a single region, but it's also available for globally distribute applications. Here we can see East us reads and writes are in sync. Japan East reads are also in sync, but our West US reads might be a little bit slower,
but we're still going to get the data in a consistent manner. Primary here is the user session is going to have consistency with reads and writes.
Next, we have consistent prefix.
This is making sure we never see out of order, reads and writes. While it may be delayed, we're still going to write operations and get read operations in the same order and finally, we have eventual. This is our weakest form of consistency and changes within the groups are gonna eventually conf er, JJ.
But it might be a while, and it might actually come out of order.
As you can see down here in the West, U. S. And Japan East,
I'm gonna discard any changes here. And let's go check out our keys.
Much like we've seen with other azure service is we have our your eye in primary and secondary keys and connection strings we can use to access our cosmos account inside of our applications. Here we have read right keys that are available to us.
But we also have read only keys that we can use. And, as always, we can regenerate thes as needed.
Now that we've looked at some of our settings that we can configure for our account, let's go check out data explore
inside a dead explorers how we can actually set up our databases containers and work with our items directly here in the portal.
And you can see we have our sequel ap I, which is what we selected when we first created our account. And this is the only a P I will be able to use to interact with our data.
So first, let's go ahead and select on new container
and we go to create our container. We have the option of creating a database I d. Which is just a name space to hold multiple containers. Or we can use an existing Since I don't have one yet. Let's go ahead and create a new one
next week and configure Arthur, Put, which is based on our request units are our use. I'll just leave this at 400 at the lowest in right now.
Next, we need to enter in a container I d.
And then we're gonna enter in a partition key for our data
here. I'm going to say our student, i d.
Now that we have our students database in our records container, we can expand out records
and take a look at our items.
Let me collapse this window over here,
and right now we don't have any items inside of our container. So let's go ahead and create a new item.
Holier idea at one.
And our items are gonna be formatted in Jason syntax.
Let's put in one for our student I d which is gonna be our partition key.
And we'll put in some other information here,
and I'm going to create another record. So I'm gonna copy all this so I can use it again.
You can see when we create our item, it's gonna add some other metadata information to it. Let's create another item.
Let's save this one as well.
Now that we have a couple items, we can sit here and perform a filter across it.
So let's edit our filter
here in the filter window. It has a couple of examples we can use. Let's say we want to find all the students with the same last name of Smith.
This is gonna pull back both of our records because both of our students right now both have the same last name is Smith.
Let's go back and edit this.
Let's do a filter based on Major.
When we apply this, we should just get back our one record
of Jane Smith, who is a computer science major.
So hopefully this demo kind of gives you a better idea of some of our concepts around Cosmos D Be especially, understand the formatting hierarchy of our account databases, containers and then items as well a setting up multi region functionality and setting up our consistency levels. Let's jump back to the slides and wrap this up.
That does it for Cosmos. DP Coming up. Next, We're gonna take a look at another database service available inside of Azure with an introduction to Azure sequel databases. See you in the next episode.
Up Next