How To Deploy Azure Cosmos DB [Step-by-Step]

Overview of Azure Cosmos DB

Azure Cosmos DB is a fully managed NoSQL database for modern app development. It is a fully managed service, Azure Cosmos DB takes database administration off your hands with automatic management, updates, and patching. It also handles capacity management with cost-effective serverless and automatic scaling options that respond to application needs to match capacity with demand.

End-to-end database management, with serverless and automatic scaling matching your application and TCO needs. Cost-effective options for unpredictable or sporadic workloads of any size or scale, enabling developers to get started easily without having to plan or manage capacity.

Advertisement

 

Prerequisite

  • Azure Subscription
  • Understanding of NoSQL database

 

1. Access Azure Cosmos DB

Azure Cosmos DB is one of the best-managed services used for NoSQL. You can see this service in the Databases pane.

How To Deploy Azure Cosmos DB [Step-by-Step]

 

2. Configure Azure Cosmos DB API

Azure offers multiple database APIs as per the below image which includes the Core (SQL) API, API for MongoDB, Cassandra API, Gremlin API, and Table API.

These APIs allow your applications to treat Azure Cosmos DB as if it were various other databases technologies, without the overhead of management, and scaling approaches.

How To Deploy Azure Cosmos DB [Step-by-Step]

 

2.1 Basics Configuration

For this article we are using Azure Cosmos DB API for MongoDB here we have a few options that we should understand.

Capacity Mode

  • Provisioned Mode: - In provisioned throughput mode, you have to commit to a certain amount of throughput (expressed in Request Units per second) that is provisioned on your databases and containers. The cost of your database operations is then deducted from the number of Request Units available every second.
  • Serverless: - Azure Cosmos DB serverless lets you use your Azure Cosmos account in a consumption-based fashion where you are only charged for the Request Units consumed by your database operations and the storage consumed by your data. Serverless containers can serve thousands of requests per second with no minimum charge and no capacity planning required.

How To Deploy Azure Cosmos DB [Step-by-Step]

 

2.2 Global Distribution

In the next step, we have the Global Distribution option which is very helpful for High Availability and resilience.

Advertisement

Geo-Redundancy: - It is a globally distributed database system that allows you to read and write data from the local replicas of your database. Azure Cosmos DB transparently replicates the data to all the regions associated with your Cosmos account.

Multi-region Writes: - Cosmos accounts configured with multiple write regions cannot be configured for strong consistency as it is not possible for a distributed system to provide an RPO of zero and an RTO of zero. Additionally, there are no write latency benefits on using strong consistency with multiple write regions because a write to any region must be replicated and committed to all configured regions within the account.

Availability Zones: - Cosmos DB uses AZ which results in increased SLAs, as availability zones are physically separate and provide a distinct power source, network, and cooling. Enabling redundancy across availability zones makes Cosmos DB resilient to entire availability zone outages at the cost of increased charges.

How To Deploy Azure Cosmos DB [Step-by-Step]

 

2.3 Networking

In the Networking tab, we have three options as we have seen those configurations in other Database services. We have all networks, public endpoint, Private endpoint.

The private endpoint will create new DNS endpoints with private IP and in public endpoint DB will be accessible over the internet.

How To Deploy Azure Cosmos DB [Step-by-Step]

 

2.4 Backup Policy

In the Backup Policy tab, we have two options periodic and continuous.

Advertisement

Periodic Policy: - In this backup mode for all existing accounts. In this mode, backup is taken at a periodic interval and the data is restored by creating a request with the support team. In this mode, you configure a backup interval and retention for your account. The maximum retention period extends to a month.

Continuous Policy: - In this policy it allows you to do restore to any point of time within the last 30 days. You can choose this mode while creating the Azure Cosmos DB account.

How To Deploy Azure Cosmos DB [Step-by-Step]

 

2.5 Encryption

And another option is to encrypt your data. By default, we have a Service-managed key, but you want more you can go with a Customer-managed key.

How To Deploy Azure Cosmos DB [Step-by-Step]

 

2.6 Confirm and Create Azure Cosmos DB

And last, we have configured everything as required then we can validate and review the changes. after validating that we can click Create.

How To Deploy Azure Cosmos DB [Step-by-Step]

 

3. Connect Azure Cosmos DB

We can connect Azure Cosmos DB using multiple ways to access data. Azure Cosmos DB Explorer and Azure Storage Explorer are both the most used tools.

You can go to the  https://cosmos.azure.com/ here you can use connection strings from Azure Cosmos DB Connection String Pane.

Advertisement

Cosmos Explorer

 

Once you log in and connect you can see the database overview pane. From here you can create Databases and collections. You can select Database throughout here we have two options Auto scale and manual.

Cosmos Explorer

 

4. Create Database and Collection

In the same way, you can create collections. You can see options as per the below image.

How To Deploy Azure Cosmos DB [Step-by-Step]

 

5. Using Local Emulator for Azure Cosmos DB for development

The Azure Cosmos DB Emulator provides a local environment that emulates the Azure Cosmos DB service for development purposes. Using the Azure Cosmos DB Emulator, you can develop and test your application locally, without creating an Azure subscription or incurring any costs.

you can download it using the below link https://aka.ms/cosmosdb-emulator

Cosmos Emulator

 

Using the Explorer option, you can create the database in the same way we did for Cosmos DB that we deployed in subscription.

Cosmos Emulator

 

Summary

As per the article, we understood that Azure Cosmos DB is managed service provided by Azure. after reading this article you would understand how you can deploy Cosmos DB in Azure with required configurations.

Advertisement

also, we got an understanding of how we can connect to Azure Cosmos DB and as well we can deploy and test on the local machine before deploying it to production.

 

References

Azure Cosmos DB documentation

 

Didn't find what you were looking for? Perform a quick search across GoLinuxCloud

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can either use the comments section or contact me form.

Thank You for your support!!

Leave a Comment

X