You are deciding on which database you should use for your web app, searching for NoSQL database and coming cross MongoDB. “MongoDB has been #1 in the NoSQL category!” She is the one! Oh, wait a sec, what are the other options? Firebase, CouchDB, DocumentDB.
If you are not only looking for a NoSQL database, but also prefer to manage your web app project in one place, Microsoft Azure IS the one!
Microsoft Azure is a cloud computing platform offering 66 products and services. To get started with Azure and its NoSQL services, jump to the Get Started with Azure section. If you need to be convinced that Azure is the one, be sure to read the section entitled Three Reasons to Use Azure in Your Web App.
For those who are familiar with MongoDB, the section Switch from MongoDB to Azure NoSQL Services will show you that it is easy to pick up Azure NoSQL databases with your existing MongoDB knowledge. I will focus on a comparison of implementations between Azure DocumentDB and MongoDB, and show you how to think about data in DocumentDB. Hopefully, by the end of this section, you will agree with me that DocumentDB is easy to learn, and worth learning.
3. Reasons to Use Azure in Your Web App
Reason 1 – Cloud Computing Means Anyone, Anywhere
One of the greatest advantages of using Azure is that all team members can access it from anywhere. For example, DocumentDB is PaaS (Platform-as-a-Service) by design, whereas MongoDB is not. Which means, if all data for the web app is stored in DocumentDB, this environment is ideal for both testing, as all team members can work with the same database, rather than creating their own test cases and dummy data using MongoDB, and run it in a localhost environment.
Although MongoDB launched its own hosted service, called MongoDB Atlas, this year, one thing may put you off immediately – after signing up with your email, it asks for payment, whereas Azure offers you a 30-days free trial before charging for these services.
Reason 2 – Host Your Own Web App Easily
No matter whether you are writing this web app for your university degree, for your work, or even just for fun, you do not want this piece of code to get wasted. Sooner or later, you will start searching for a host provider. Azure can be your long-term solution for web hosting.
Reason 2.1 – Protocol Support for MongoDB
When I was exploring all Azure offers, it made me feel like you can always get something out of it. What if you already have an existing MongoDB app, and it is too late to start with DocumentDB? DocumentDB provides protocol support for MongoDB. For a step-by-step guide, follow the link here.y managed and scalable NoSQL databases – while continuing to use familiar skills and tools for MongoDB.’
Reason 2.2 – Azure App Service
If you hate to start from scratch and prefer your project to proceed in an organized manner, Azure App Service can create your web app in three steps. It not only provides you with a HTTPS URL to host your web app, but also provide you with a well-structured project directory with some basic code for you to get started with. The following steps give you with a general idea as to how to develop your first web app to Azure, and for more information, follow the link here.
|Step 1: Select app type from
– Web App,
– Mobile App,
– Function App,
– Logic App,
– API App;
|Step 2: Select template from
– ASP.NET Core 1.0,
– ASP.NET with Azure Search Site,
– Empty Site,
– Java Coffee Shop,
– MCV 5 With Entity Framework;
|Step 3: Finally, your web app has been created and you can work with your app as seen below by
– Edit your code online with Visual Studio,
– Download web app content,
– Download publishing profile,
– Clone or push with git.
Here I have selected 1. Web App => 2. ExpressJs. And the following image is the screenshot from the ‘Edit your code online’ page. Everything is setup, and it is time to start coding!
Reason 3 – There is Something More for Your Web App
For team development, get started for free with Visual Studio Team Services here. Along with DocumentDB and Azure App Service, these services should setup an efficient platform for your web app development.
For maintenance and further improvement, it is critical to analyze logs. You may also be interested in exploring Log Analytics (more information here), combined with Stream Analytics (more information here) for real-time data stream processing, and/or Machine Learning (more information here) for cloud predictive analytics.
Switch from MongoDB to Azure NoSQL Services
Microsoft Azure provides NoSQL services such as:
- Azure DocumentDB
- Azure Table Storage
- Azure HBase as a part of HDInsight
- Azure Redis Cache
|Environment Variables for Connection||· Host endpoint
· Database account master key of the endpoint
|· The database on our locally running instance of MongoDB|
|· Database to be created. Whereas in MongoDB it is an environment variable for connect.
· Schema Free.
|· Flexible schema to be created.
· Model – a class with which we construct documents. Similar to collection in DocumentDB.
|CRUD (Create, Read, Update, Delete)||The link here provides a summary about sample solutions for CRUD as well as other operations and API references on database, collection, document.||Documentation here for CRUD operations on documents.|
|Indexing||B-tree data structure|
|Automatically handle all aspects of indexing. For customized indexes, follow the link here.||Documentation here for handling indexes.|
Due to the nature that both databases are document-oriented, some aspects – such as CRUD operations – are handled in a similar way. You may need to spend some time thinking about how to model your data in DocumentDB if you are used to MongoDB schema. The article ‘Modelling data in DocumentDB’ here may sharpen your way of thinking data in DocumentDB.
There are posts providing a nice comparison between DocumentDB and MongoDB in terms of:
- Scaling – Sharding and Replication
- Native REST interface
- Data Interchange Format
For further reading, I would highly recommend:
David Green, ‘MongoDB vs. Azure DocumentDB’, April 2015, which provides a detailed comparison in terms of all the aspects I mentioned above.
To learn more about other Azure NoSQL technologies, read David Chappell, 2014, ‘Understanding NoSQL on Microsoft Azure’.
Get Started with Azure
1. Create your Azure account
Step 1: To create your Azure account, follow the link here. Click Start for free for 30 days free trial.
Step 2: It will lead you to the sign up page as seen below. Notice here it will ask you for Identity Verification by Phone and Identity Verification by Card. Your credit card will not be charged for this offer unless you explicitly remove the spending limit. For more information regarding the free account, see the FAQ here.
Note: If you are a university student, you can follow the link here to Create a Microsoft Image profile first. After getting verified as a student, follow the link here to Get Microsoft Image with Azure. This benefit should provide you access to the following services (more information here):
- Azure App Services
- SQL Database
- MySQL Database from ClearDB
- Visual Studio Application Insights
- Visual Studio Team Services
But please be aware that you will probably run into the issue as seen below in most cases. Bad! So I would recommend providing your credit card information in exchange for services with full features.
2. Azure Portal
Follow the link here to sign in to Azure Portal and start your Azure journey. Azure Portal is the console where you can manage all your Azure products/services. Following is the dashboard displayed when you sign in to the portal.
3. Create Azure DocumentDB NoSQL Account and Document Explorer
Follow the link here to create your Azure DocumentDB NoSQL account. Then, while still in the Azure portal, you can launch Document Explorer by following the link here to view JSON objects created using DocumentDB.
4. Create Azure Storage Account and Microsoft Azure Storage Explorer
Follow the link here to create your Azure storage account to get started with Table storage. This account also allows you to work with other storage services such as Blob. Later, you will need an Account Name and Access Keys to create connections in your Web App server and view data in Microsoft Azure Storage Explorer.
To view all data in, for example, Table Storage, download Microsoft Azure Storage Explorer here. After opening the explorer, to connect to Azure Storage, follow the steps below. This step-by-step guide applies to other Azure Storage services such as Blob Storage.
Step 2: Enter Access Key obtained after creating the Storage account on Azure portal, then click Next.
Step 3: Select Use an account name and key to connect to an Azure Storage account and click Next.
Step 4: Enter the storage account name and click Connect.
Step 5: You should be able to find your storage account under Storage Accounts.
To summarize, Microsoft Azure is perfect to manage your web app project in one place. It provides lots of services such as App Service, Visual Studio Team Services, DocumentDB, Stream Analytics and so on, and each helps with your web app at different stages – set up, development, testing, maintenance and further improvement.
MongoDB is great as a NoSQL database with its strong consistency, flexibility, scalability and performance, but for an organized web app project, Microsoft Azure is a better solution. Pricing may be the biggest turnoff, but you get 30 days to make up your mind.
In the meantime:
Microsoft Imagine, anywhere, anytime:
- Follow us on Twitter, Facebook, Instagram and YouTube.
- Subscribe to our blog to meet students just like you who are changing the world with their exciting new tech. Plus, stay on top of all the new products and offerings for students.
- Head on over to Microsoft Imagine where, if you haven’t already, you can create a Microsoft Imagine student profile, giving you access to developer tools, online training, developer competitions and the bi-monthly Microsoft Imagine newsletter.