MongoDB to CosmosDB Migration Demo

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

Already have an account? Sign In »

Time
14 hours 28 minutes
Difficulty
Intermediate
CEU/CPE
15
Video Transcription
00:00
>> Hello, Cybrarians.
00:00
Welcome to Lesson 3.12 of Module 3 of discuss titled,
00:00
AZ-301, Microsoft Azure Architect Design.
00:00
Here are the tasks that we'll be covering in this demo.
00:00
We'll start out by reviewing
00:00
the migration scenario that I'll
00:00
be walking you through today.
00:00
First in this migration scenario,
00:00
we have two environments,
00:00
an Azure environment and an on-premises environment.
00:00
In the Azure environment,
00:00
there's an Azure App Service that hosting
00:00
the Tailwinds e-commerce site and there's
00:00
an Azure SQL Database that's hosting
00:00
the catalog data for the e-commerce site.
00:00
On-premises does a server that's running MongoDB,
00:00
and that database is hosting
00:00
the shopping cart for our e-commerce site.
00:00
Now how are we creating
00:00
an Azure Cosmos DB account that uses the MongoDB API?
00:00
This will be our database migration targets.
00:00
I previously created
00:00
an Azure Database Migration Service in
00:00
my earlier demonstration on
00:00
migrating SQL from on-premises to Azure.
00:00
I'll be using that same
00:00
Database Migration Service and I'll be suing it to
00:00
migrate the MongoDB database from
00:00
on-premises to Azure Cosmos DB.
00:00
Finally, I will modify my web application in
00:00
Azure to use the Cosmos DB
00:00
rather than the on-prem MongoDB.
00:00
Let's move on to the next part of this demo.
00:00
Now what I'll do next is I'll take
00:00
you over to the e-commerce site,
00:00
our add shopping information into the shopping cart.
00:00
Then you can see that this information
00:00
>> is indeed saved in
00:00
>> the on-premises MongoDB database.
00:00
Let's go ahead to do that.
00:00
Here I am in my e-commerce site,
00:00
Tailwind Traders e-commerce sites that's currently
00:00
using this Azure SQL server
00:00
for the shopping catalog information.
00:00
All this information that we're seeing here,
00:00
this data is stored in the shopping catalog,
00:00
which comes from Azure SQL or a database om Azure SQL,
00:00
but information that's saved for
00:00
the shopping cart is stored in
00:00
MongoDB and that's on-premises.
00:00
Let's go ahead and login as a user of this website.
00:00
I put in my username and I put in my password,
00:00
my email, and my password.
00:00
Now I'm logged into this e-commerce site.
00:00
I'll go ahead and add a few items to the shopping cart.
00:00
I'll add that to the list.
00:00
I'll add a few other items to the list or to the cart.
00:00
Let's get some DIY tools. Let's add those.
00:00
We currently have three items in the shopping cart.
00:00
I'll go over now to the Cloud Shell and I'll log in or
00:00
authenticate to my MongoDB server on-premises.
00:00
Let's SSH into the MongoDB server
00:00
on-premises and put in my password,
00:00
and let's elevate privileges.
00:00
I'll clear the screen.
00:00
I'm currently on my MongoDB server on-premises.
00:00
If I go over to the Mongo command line and I
00:00
do a show dbs.
00:00
That shows me I have three databases,
00:00
which I have the Tailwind database here.
00:00
What I can do is I can switch over
00:00
to use this Tailwind database.
00:00
Let's use Tailwind.
00:00
Let's change that.
00:00
You Tailwind and I'm switched over to
00:00
use my Tailwind database.
00:00
If I go ahead and show collections,
00:00
and I can see that I have one collection called carts.
00:00
That's the shopping carts for our websites.
00:00
The other thing that I'll do is
00:00
>> if I do a db.carts.count.
00:00
>> Let's see how many items.
00:00
We currently have two items in the shopping cart.
00:00
If I go back to my e-commerce website
00:00
and let's go over and add a few terms.
00:00
Let's add that item to the cart.
00:00
Now, we've got four times.
00:00
Let's add some kitchen accessories. Let's add that.
00:00
Now I've got five items in the shopping cart.
00:00
If I go back to my MongoDB server,
00:00
and if I do that, you can see I have
00:00
five items and by the way,
00:00
I can also review the items.
00:00
If I do a db.cart.find,
00:00
and if I run that, you can see
00:00
the items that I have in the shopping cart.
00:00
That includes the door,
00:00
adware kits, and go and all this other information.
00:00
But this is all the items that are currently in
00:00
the shopping cart. That's good.
00:00
The next video that I'll show you in this demo
00:00
is the creation of a new Cosmos DB account.
00:00
Now, I've already pre-created
00:00
the Cosmos DB accounts that I'll be using,
00:00
but I just want to walk you through
00:00
that process very quickly.
00:00
I'm back in the Azure Portal as the Cosmos DB accounts
00:00
that are already pre-created and to use.
00:00
If I go over on the Data Explorer,
00:00
I can see that there is a Tailwind collection,
00:00
but there's no items that exist within this collection.
00:00
It has absolutely no items in it.
00:00
That's the one that I'll be using.
00:00
But let me walk you through
00:00
the creation of a CosmosDB account from scratch.
00:00
Let's go back to the Azure portal.
00:00
Let's click on Create a resource,
00:00
and let's search for Cosmos, Azure Cosmos DB.
00:00
I click on that and I click on Create.
00:00
Now I specify a resource group for this.
00:00
Let's specify the other resource group. Give it a name.
00:00
Azure Cosmos 02.
00:00
I can specify the API.
00:00
In this case of my migration,
00:00
I'm using Azure CosmosDB for MongoDB API.
00:00
That's what I'm using, but we
00:00
can select any of these API.
00:00
I'll stick to the one that I used and I'll
00:00
specified the region that
00:00
this should be deployed into other location.
00:00
I can specify the version
00:00
of the MongoDB protocol that this will support,
00:00
3.6 or 3.2 are the options that are available.
00:00
I can specify my level of redundancy and if I
00:00
want multi-region wright are
00:00
>> just a single region write.
00:00
>> Once I specify all those configuration parameters,
00:00
I can go on the network
00:00
where I can specify we'll be able to
00:00
connect to this CosmosDB account over the network.
00:00
I can use something called service
00:00
endpoints to lock this down,
00:00
to only accept connections from within
00:00
a network that I control.
00:00
I can choose to do that.
00:00
For now, I'll just leave that now.
00:00
I'll just go to next.
00:00
I'll just click on Review and Create.
00:00
It's as simple as that to create a CosmosDB database.
00:00
Now that I have my CosmosDB Database,
00:00
the next that I'll be showing you is the migration of
00:00
my MongoDB database using
00:00
the Azure Database Migration Service.
00:00
Visual representation of what I'll be showing you,
00:00
it's the migration over there.
00:00
Let's get on with it. Here I am back
00:00
>> in the Azure portal.
00:00
>> You can see my Azure Database Migration Service here.
00:00
If I click on that,
00:00
I can go ahead and create
00:00
a new migration project. Let's do that.
00:00
I click on New Migration Project.
00:00
I give the project a name, say make Mongo.
00:00
I can select my source server type.
00:00
In this case, it's MongoDB.
00:00
If I select MongoDB and
00:00
the only target option that I have
00:00
is CosmosDB, MongoDB API.
00:00
Great. If I go ahead and choose my type of activity,
00:00
I can either do an online or offline migration.
00:00
Having an offline migration,
00:00
online migration has the lowest impact
00:00
on the application downtime.
00:00
That's what you preferably want,
00:00
because it keeps both databases in sync.
00:00
But for now, I'll just select offline migration.
00:00
What I'll do is I'll go ahead and click
00:00
create and run activity.
00:00
That takes me to the option where I
00:00
can complete the rest of the configuration.
00:00
With the mode, I'll say connection string mode.
00:00
I'll put in the connection string for
00:00
my MongoDB database on-premises.
00:00
As the connection string from on-premises
00:00
MongoDB database, I click on Save.
00:00
Then I can specify my CosmosDB
00:00
>> connection string target.
00:00
>> For the CosmosDB connection string target,
00:00
what I can do is I can actually go in to select
00:00
my subscription and select
00:00
the CosmosDB database over here.
00:00
So I want the mod 20 mod 3 Mongo.
00:00
That's what I want. I'll select
00:00
that CosmosDB database of the day.
00:00
After I've selected that,
00:00
I go ahead and I click on Save.
00:00
Now you can see I can specify
00:00
configuration for this collection.
00:00
For example, what about the true PUT request units?
00:00
Do I want to configure?
00:00
I'll just go ahead and leave that as defaults.
00:00
I'll go ahead and click on Save.
00:00
I can see the collection that would be
00:00
migrated from on-premises, the cart collection.
00:00
I'll go ahead and click on Save to that.
00:00
I can also change the request units there.
00:00
Then I give the activity a name,
00:00
which I'll call the same name, Mongo activity.
00:00
I'll click on Run migration
00:00
and the migration process starts.
00:00
This is something that would just take a few seconds.
00:00
There's not much data in the database anyway,
00:00
but you can see now that it's showing as Completed.
00:00
That's good. The first thing that I'll
00:00
do is it's trained as completed.
00:00
Let's go back to
00:00
my resource group and let's go
00:00
select my CosmosDB account.
00:00
If I go under Data Explorer.
00:00
Under Data Explorer,
00:00
you can see that this cart collection has been
00:00
migrated on the database, which is great.
00:00
I can see the high temps that are in it,
00:00
1, 2, 3, 4, 5 items,
00:00
which are the items that I have in
00:00
my cat when I'm using the MongoDB On-premises.
00:00
That looks good. Let's move
00:00
on to the rest of the process.
00:00
The next thing that I'll do is I'll show
00:00
you the modification of
00:00
my Azure Web app to use the CosmosDB database
00:00
I just migrated into.
00:00
Back in the Azure portal,
00:00
if I go back onto my resource group and I
00:00
select my Azure App Service.
00:00
What I'll do is if I go under configuration.
00:00
Under configuration, there is
00:00
the MongoDB connection string over here.
00:00
If I go ahead and click on that.
00:00
I'll modify this from pointing
00:00
on-premises to pointing to my Azure CosmosDB.
00:00
Let's go ahead and do that.
00:00
Now the great thing about this is,
00:00
I'm now modifying my application in anyway.
00:00
CosmosDB supports the MongoDB wire protocol
00:00
and I don't need to modify my application in anyway.
00:00
Just carries and talk into CosmosDB.
00:00
The same way it would talk into MongoDB.
00:00
Let's go ahead and click "Okay" on that.
00:00
If I click Save on that,
00:00
that's going to restart the web application
00:00
and everything should be back in a few seconds.
00:00
You can see that that's currently
00:00
using the on-premises database.
00:00
We just need to wait for each to finish
00:00
restarting and then I'll do my refresh.
00:00
I expect soon I'll be using CosmosDB.
00:00
Let's refresh the slides.
00:00
You can see that that's now using
00:00
my CosmosDB and I still have my cart all intact.
00:00
If I go ahead to some other items in the cart,
00:00
let's add that to the list.
00:00
Now I've got six items.
00:00
Now I've just migrated MongoDB from
00:00
on-premises over to CosmosDB in Azure.
00:00
That's awesome. That brings
00:00
me to the end of this demonstration.
00:00
I hope it's been useful for you.
00:00
Thanks for watching. I'll see you in the next lesson.
Up Next