Quickstart Series: Cosmos DB + MongoDB in Azure

Here’s some brand new content from the SoftwareArchitect.ca YouTube channel that you might find interesting.

In this video, I show you how to create a MongoDB Databased in Microsoft Azure using Cosmos DB. The data is stored in CosmosDB, but the MongoDB API is compatible with the standard MongoDB API, and so you can migrate your data into CosmosDB and simply point your apps at it without coding changes.

I’ll show you how easy it is to create a MongoDB in Azure.

Quickstart Series: Windows Web App in Azure

In this video, I show you how to create a Windows Web App in Microsoft Azure. Windows Web App. We go through the Azure Portal, and see how form fields get filled in. If you can’t afford to create resources in Azure, but want to see how it’s done in 2018, this is the video for you.

Or you can see the video directly on YouTube.

Transcript:

Hi there, this is Scott Duffy of SoftwareArchitect.ca. In today’s quick start video, we’re going to go and create ourselves a MongoDB database using the Microsoft Azure Cosmos DB service. Now, in case you’re not aware, Cosmos DB is a relatively new service within Microsoft Azure that contains many different types of data models. It is actually a globally distributed, multi-model database service. What that means is that you can create, very quickly and actually cheaply, your data in the cloud, in many different regions of the world. It is scalable, it is guaranteed low latency, and you can choose from the key value model, or document DB model, or graph API model, or column-value model. It’s got a whole range of consistency models for you to choose from.

Microsoft offers comprehensive service level agreements, so that you’ll know exactly how much up time the application has, and how quickly you expect the application to respond. It is a database for the modern way of developing apps, contains many different languages that it can connect to, so in this video, we’re going to go into the Azure portal and we’re going to create ourselves a MongoDB database.

So I’m in the Azure portal, that is http://portal.Azure.com, and I want to create a Cosmos DB. So I go into the creator resource, and you’ll see all the options. Now, the Cosmos DB is actually right off of the getting started tab, so you can see it right off this first screen, but if I really wanted to get MongoDB, I could do a search for it. Now I’ll be given options for running MongoDB as a hosted instance within a virtual machine. Bitnami has some images. There’s also containers, if you like the docker model, but we’re looking for, Microsoft has the database as a service for MongoDB.

Now this is actually Cosmos DB. They’ve just given it another label, so that it comes up on a search for MongoDB. I’m going to close out of this, go back to the marketplace getting started tab, and go into the Cosmos DB from there. Now we have to give it a name. It has to be unique, globally unique. You see the fully qualified domain name as “.documents” Azure.com. So I’ve pre-chosen a unique ID here, and it’s unique across all of Azure. The first big question is the API. Now Cosmos DB comes with a number of API compatibilities to access the data inside, and the one that we’re curious about is Mongo DB. Okay, so you can access things like a table, which is a key value pair, the famous no sequel database Cassandra. There’s also a SQL compatible API that returns JSON, and Graph API.

But what we want to do is go to Mongo DB. We’ve got our subscription, now you could have the free account, or you could be on a free trial, or MSDN subscription. This is my own subscription. I’m going to put these into a resource group. I’ll use the same ID as the Cosmos DB. Pick one of the regions, now I believe Cosmos DB is supported through all of Microsoft’s regions, so you’ll see a lot of options from Europe, North America, South America, Australia, et cetera. I’ll just choose the default.

Geo-redundancy, this allows my data to be created in West US and East US, and I can add other regions later, so this is so that if there’s a disaster, it adds to the availability of your solution. Now the new security feature here is to configure virtual networks, and if you do this, this allows you to restrict access. So instead of your Cosmos DB having a public URL, you still need, of course, security to access it, but if you just wanted to block off access to it, you could configure this to a virtual network, and only other machines on the virtual network on the subnet can use the Cosmos DB. So if you have an application on Azure, and you want to create a Cosmos DB only for that application, you can enable this, but I will leave it disabled.

Pin to dashboard, and I will click create. Now that did take a few minutes, but Microsoft Azure did come back and create me a new Cosmos DB account. You can see here that I selected geo-redundancy, so I have the primary database in the western US, but there is a readable location in the eastern US, and I can get the connection strings and start using it as a Mongo DB database. This is, again, an alternative to hosting MongoDB yourself, in your own data center. You can use Cosmos DB using a MongoDB API. If I go under the quick start tab of the settings, it actually gives me some sample code I can pull in the connection string into .NET, or if I am a Python developer or Node.JS, et cetera, there’s other ways of getting it. It gives me my user ID and password for the connection string, so using Azure for your MongoDB needs is as quick and easy as this video.