We continue our article series dedicated Microsoft Azure. In previous articles, we’ve talked about Azure SQL Database, SQL Server on Azure VMs, Azure Advisor, etc. In this article, we will talk about what Azure Cosmos DB is, as well as see a simple step by step example on how to enable it and access it from the Microsoft Azure Portal.
What is Azure Cosmos DB?
As defined on MS Docs, Cosmos DB is a “is Microsoft’s globally distributed, multi-model database“. As described on Wikipedia, the Greek philosopher Pythagoras first used the term “cosmos“ for the order of the universe. In Greek, the word is written “κόσμος“. It is not random that this word is used in Azure Cosmos DB. Cosmos DB enables you to store and access data/documents across any number of Azure’s geographic regions. You can easily set your data to easily replicate across data centers all over the world (wherever there is an Azure data center) thus having them globally distributed. This guarantees high throughput, latency, availability, and consistency, based of course on the agreed SLA.
Main Technical Characteristics
The main technical characteristics of Azure Cosmos DB are:
- Ability to globally distribute your data
- Multiple data models and APIs for working with your data
- You can elastically and independently scale throughput and storage on demand and on a worldwide basis
- Ability to build highly responsive and mission-critical applications
- Ensure “always on” availability
How you can Set Up Azure Cosmos DB – A Simple Example
Let’s see a simple example of setting up Cosmos DB in Azure Portal.
Step 1: Create a resource
You create a new resource along with searching for cosmos. As you can see, the “Azure Cosmos DB” resource appeared in the search results.
Step 2: Click on the “Create” Button
Step 3: Create an Azure Cosmos DB Account
On this page, you enter the basic settings.
Next, you specify the network settings.
Then, if you you like, you can set tags for categorizing resources (i.e. for billing view purposes).
Then, the summary page is presented, where a validation of your settings takes place. In my example, validation was successful.
Step 4: Wait for Deployment to Complete
…and right after deployment is completed, you can now access your Azure Cosmos DB accounts.
Step 5: Access your Azure Cosmos DB Account
The next step is to access your Azure Cosmos DB account and see the overview. In the overview page, it is important to see the status of the service. In my example, you can see that the status is “Active”.
That means that the service is ready to be used.
Note: In order to have Portal access to your Azure Cosmos DB account and perform certain actions, you might need to update your firewall rules accordingly.
Step 6: Working with your Data on Azure Cosmos DB
As mentioned in the “Main Technical Characteristics” section of this article, Azure Cosmos provides multiple data models and APIs for working with your data. For example, currently you can use the below APIs (more APIs are coming soon):
- SQL API
- MongoDB API
- Cassandra API
- Gremlin API
- Table API
Similarly, there is a variety of platforms via which you can work with your Azure Cosmos DB account.
A Simple To-Do App
In this example, I navigated to “Quick Start” and I chose the .NET platform via which I will work with data on my Azure Cosmos DB account:
After choosing the “.NET” platform, I click on the “Create ‘items’ collection” button, and a download appears containing a quick start .NET project which will help me to easily work with data.
I compiled and ran the sample .NET project and a local webpage came up, allowing me to create a simple document on my Azure Cosmos DB account. This project is just a simple example (i.e. a to-do app) for just illustrating how easy is to access your Azure Cosmos DB account from a client, in this case, a .NET program.
Here’s the first page of the sample program:
Now, let’s add an entry:
Checking your Data with Azure Cosmos DB Data Explorer
Now, I navigated back to the Azure Portal, and via my Cosmos DB account, I clicked on the “Data Explorer” link.
Then, via a simple SQL statement, I can see that the data (1 record) I previously added using the .NET app, is there and available:
High Availability – Replicate Data Globally
Now here’s the cool stuff!
When you click on the “Replicate data globally” link, the World map is presented (remember the explanation of the word “cosmos”? 🙂
On this map, you can see the regions (that is the available Azure data centers) in which my data is currently located. The regions are categorized as “Write” and “Read” regions.
Currently, my data is only available on one data center, that is “West Europe” (Write Region).
Now, see how easy is to replicate your data to another region!
I have just clicked on the “North Europe” data center and clicked on the “Save” button.
After you click “Save”, your Azure Cosmos DB data starts replicated to the newly added region. In my example below, you can see that North Europe is being set as a Read Region.
A few minutes later, replication is completed, and as you can see, my data is now available on two regions/data centers:
Azure Cosmos DB is a globally distributed, powerful multi-model database. Along with the proper SLA, this guarantees high throughput, low latency, as well as high availability and consistency.
In this article, we talked about what Azure Cosmos DB is and discussed its main characteristics. We also went throughout the process of create and accessing and Azure Cosmos DB account via a comprehensive step-by-step example with screenshots. Moreover, we saw how easy it is set global replication for your data.
In subsequent articles, we will explore more Cosmos DB as well as other cool Azure/Cloud data technologies.
- Learn Azure SQL Database: Creating your First Database
- How to Create an Azure SQL Server Virtual Machine
- How to Backup a SQL Server Database from On-Premises to Azure Storage
- What is Azure Advisor?
- … all our Azure-related articles
Check our latest software releases!
Easily generate SQL code snippets with Snippets Generator!
Convert static T-SQL to dynamic and vice versa with Dynamic SQL Generator.
Secure your SQL Server instances with DBA Security Advisor.
Benchmark SQL Server memory-optimized tables with In-Memory OLTP Simulator.
Rate this article:
Reference: SQLNetHub.com (https://www.sqlnethub.com)
© 2018 SQLNetHub