hi welcome to another Azure .NET QuickStart my name is Jeremy Likness I'm
a cloud developer advocate and today I want to show you a fast way to get up
and running with cosmos DB I'm following the azure cosmos DB QuickStart that's
right on docs.microsoft.com our first step is to go into the portal and click
new and we're gonna select cosmos DB that's our globally distributed no
SQL database it's going to spin up and give us a few options to set up what
we're going to call this database account or host for what we're going to
run and load our data into
now Azure cosmos DB is prompting me for a unique ID I'm gonna call this my
QuickStart DB for the database it'll ensure that that's unique and we're
going to use the SQL document DB interface for this for a resource group
I'll create a new one call it cosmos DB QuickStart group and I'm going to keep
the default location of East US we'll pin this to the dashboard for easy
access and click create and this will spin up the account that's going to host
our various data and collections for us
now as you can see the cosmos database is set up in the portal and fortunately
we've got a quick start tab that makes it easy to get up and running with data
if you'll notice I have a button here create the items collection I'm going to
click that button little that'll do for me is load a new collection that's ready
for me to add data into so if we go back to the overview and we refresh this we
should see a list of the collection here's the to-do list collection we'll
navigate inside of that and we've got an items collection for data so I'm going
to pick a new document and for that new document will add some sample data this
comes right off of the QuickStart if you take a look at the steps in the
QuickStart there's a sample data document item that you can copy and
paste right into the portal so we'll come back here and click Save and that
will add that data and then I'm just going to add a second item with an ID of
two we'll make the description pick up blackberries and it's another good item
watermelon so I'm going to just change that and click update for that and now
we should have this populated so the next step that we'll take is in the
quick start notice that we've got the option to download our own dotnet app
this is going to give me a zip file that has a fully loaded project ready for me
to connect to my cosmos DB if I come inside this project what I want to do is
first show you this repository class this is the class that makes the various
connections to cosmos DB you can see with the document API it's as easy as
read document async to pull in a sample document and then for example when we're
getting the list of items it creates a very simple query that's passed to the
database and pulls back those items I want to run this application but first I
need to set up my secrets there's two secrets that we provide for this
application these are going to be available in the keys tab within the
portal the first is the import we'll copy that in point that's how it
accesses the cosmos DB so I'm going to paste that directly into my web config
and the second is a primary key and this is a key you want to keep safe you
wouldn't normally share it like I'm doing here you'd want it configured
within your application settings because this is a secret that allows access to
the database once we've got that in place we'll click debug to launch the
application let that spin up and what's happening right now is my web browser is
opening and setting up client-side debugging through Chrome it's going to
refresh to the localhost endpoint and you can see that the item that I
inserted through the portal is here I can create a new item we'll give it a
name new task this is actually working and we'll click create the list shows
that task we can click it as edit and make it complete and save and it drops
off the list so there you have it the fast easy way to get started working
with cosmos DB right out of the portal