{"id":1902,"date":"2020-10-27T08:00:58","date_gmt":"2020-10-27T15:00:58","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/cosmosdb\/?p=1902"},"modified":"2020-10-26T17:23:50","modified_gmt":"2020-10-27T00:23:50","slug":"leverage-your-mongodb-skills-on-azure-cosmos-db","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cosmosdb\/leverage-your-mongodb-skills-on-azure-cosmos-db\/","title":{"rendered":"Leverage your MongoDB skills on Azure Cosmos DB"},"content":{"rendered":"<p>You understand the value of the flexibility and scalability of <a href=\"https:\/\/azure.microsoft.com\/en-us\/overview\/nosql-database\/#:~:text=How%20to%20choose%20between%20relational%20%28SQL%29%20and%20nonrelational,grouped%20i%20...%20%201%20more%20rows%20\">NoSQL databases<\/a>. The document model, using a JSON style data format, supports dynamic schemas that are easy to read\/write and fast for machines to parse. Though if you want to truly unlock the potential of the distributed nature and horizontal scalability of NoSQL databases, you should consider running those databases in the cloud. <a href=\"https:\/\/azure.microsoft.com\/services\/cosmos-db\/\"><strong>Azure Cosmos DB<\/strong><\/a><strong> is a fully-managed NoSQL database with an API for MongoDB<\/strong><strong>.<\/strong> It provides cost-effective pricing models, enables fast and flexible application development, and is capable of running mission critical workloads. In this post, we\u2019ll discuss how to use your existing MongoDB skills on Azure Cosmos DB.<\/p>\n<p>&nbsp;<\/p>\n<h2>Use Familiar Syntax and Commands<\/h2>\n<p>The Azure Cosmos DB API for MongoDB is based on a wire protocol implementation, which gives you the best of both worlds: leverage your skillset in MongoDB and JSON objects, while also gaining all the benefits of Azure Cosmos DB. This lets you use the libraries, drivers, and frameworks of the MongoDB you&#8217;re used to, all while capitalizing upon the performance and scalability of Azure Cosmos DB. It also means that you can build with existing data and apps because of the compatibility with MongoDB v3.6, which provides comprehensive support for MongoDB query language constructs. A detailed list of <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/cosmos-db\/mongodb-feature-support-36\">currently supported operations, operators, stages, commands, and options<\/a> can be found in documentation.<\/p>\n<p>&nbsp;<\/p>\n<hr \/>\n<p style=\"text-align: center;\"><span style=\"font-size: 14pt;\"><em>The Azure Cosmos DB API for MongoDB powers production applications at <a href=\"https:\/\/customers.microsoft.com\/en-us\/story\/bentley-partner-professional-services-azure\">Bentley Systems<\/a>, and is integral to <a href=\"https:\/\/azure.microsoft.com\/en-us\/blog\/always-on-real-time-threat-protection-with-azure-cosmos-db-part-one\/\">Azure Advanced Threat Protection<\/a> and <a href=\"https:\/\/azure.microsoft.com\/en-us\/blog\/microsoft-365-boosts-usage-analytics-with-azure-cosmos-db\/\">Microsoft 365<\/a>.<\/em><\/span><\/p>\n<hr \/>\n<p>&nbsp;<\/p>\n<h2>Dev\/Test Free\u2026 then Scale<\/h2>\n<p>Run a workload of any size with greater control of the cost. <a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/build-apps-for-free-with-azure-cosmos-db-free-tier\/\">Free Tier<\/a> (400 RU\/s and 5GB per month free) paired with <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/cosmos-db\/provision-throughput-autoscale\">Autoscale throughput<\/a> allows you to run low-cost, scalable apps on Azure Cosmos DB. Develop, test, and <a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/running-a-low-cost-scalable-app-with-azure-cosmos-db-free-tier\/\">even deploy for free<\/a> with the capability to automatically scale up and down based on usage.<\/p>\n<p>Alternatively, you could leverage the new <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/cosmos-db\/serverless\">Serverless<\/a> model, the only serverless MongoDB on the market. Serverless is a cost-effective way to run small, spiky workloads. With this consumption-based model, you are charged for the Request Units (RU) used by your requests and the storage consumed by your data. This means that there\u2019s no minimum cost when using serverless \u2013 you only pay for what you use.<\/p>\n<p style=\"text-align: center;\"><em>Pick the right model for your workload<\/em><\/p>\n<p style=\"text-align: center;\"><iframe src=\"\/\/www.youtube.com\/embed\/aFCsCLwgczA\" width=\"560\" height=\"314\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p style=\"text-align: center;\"><em>Still not sure which to use? <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/cosmos-db\/throughput-serverless\">This guide<\/a> will help you decide.<\/em><\/p>\n<p>&nbsp;<\/p>\n<h2>Build on or Migrate to the API for MongoDB<\/h2>\n<p><strong>Create an Account<\/strong>:<\/p>\n<ul>\n<li>Create an Azure Cosmos DB account on the <a href=\"https:\/\/portal.azure.com\/\">Azure portal<\/a>\n<ul>\n<li>If you\u2019re new to Azure, first create a <a href=\"https:\/\/azure.microsoft.com\/en-us\/free\/\">free Azure account<\/a> and receive a $200 credit<\/li>\n<\/ul>\n<\/li>\n<li>To go through this process in a sandbox use this <a href=\"https:\/\/docs.microsoft.com\/en-us\/learn\/modules\/create-cosmos-db-for-scale\/\">Microsoft Learn module<\/a><\/li>\n<li>Optimize your account configuration and settings using these <a href=\"https:\/\/azure.microsoft.com\/en-us\/resources\/azure-cosmos-db-onboarding-best-practices\/\">Onboarding Best Practices<\/a><\/li>\n<\/ul>\n<p><figure id=\"attachment_1988\" aria-labelledby=\"figcaption_attachment_1988\" class=\"wp-caption aligncenter\" ><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2020\/10\/Create-Cosmos-DB-Account.png\"><img decoding=\"async\" class=\"wp-image-1988\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2020\/10\/Create-Cosmos-DB-Account-300x205.png\" alt=\"Image of process of creating Cosmos DB Account\" width=\"413\" height=\"282\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2020\/10\/Create-Cosmos-DB-Account-300x205.png 300w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2020\/10\/Create-Cosmos-DB-Account-1024x700.png 1024w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2020\/10\/Create-Cosmos-DB-Account-768x525.png 768w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2020\/10\/Create-Cosmos-DB-Account.png 1151w\" sizes=\"(max-width: 413px) 100vw, 413px\" \/><\/a><figcaption id=\"figcaption_attachment_1988\" class=\"wp-caption-text\"><span style=\"font-size: 10pt;\">Example account creation details<\/span><\/figcaption><\/figure><\/p>\n<p><strong>Build a new app<\/strong>:<\/p>\n<ul>\n<li>View <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/cosmos-db\/mongodb-introduction\">documentation on the API for MongoDB<\/a> including <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/cosmos-db\/create-mongodb-nodejs\">quickstarts<\/a> and how-to guides<\/li>\n<li>Use tutorials to create a new app written in Node.js with <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/cosmos-db\/tutorial-develop-mongodb-nodejs\">Angular<\/a> or <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/cosmos-db\/tutorial-develop-mongodb-react\">React<\/a><\/li>\n<\/ul>\n<p><strong>Migrate your data<\/strong><strong>:<\/strong><\/p>\n<ul>\n<li data-leveltext=\"-\" data-font=\"Calibri\" data-listid=\"1\" aria-setsize=\"-1\" data-aria-posinset=\"0\" data-aria-level=\"1\"><a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/cosmos-db\/mongodb-pre-migration\"><span data-contrast=\"none\"><span data-ccp-charstyle=\"Hyperlink\">Azure D<\/span><\/span><span data-contrast=\"none\"><span data-ccp-charstyle=\"Hyperlink\">atabase Migration Service<\/span><\/span><\/a><span data-contrast=\"auto\">\u00a0is great for migrating your data from MongoDB (either on-prem or a managed instance in the cloud) to\u00a0<\/span><span data-contrast=\"auto\">the<\/span><span data-contrast=\"auto\">\u00a0API for MongoDB<\/span><span data-ccp-props=\"{&quot;134233279&quot;:true,&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/li>\n<li data-leveltext=\"-\" data-font=\"Calibri\" data-listid=\"1\" aria-setsize=\"-1\" data-aria-posinset=\"0\" data-aria-level=\"1\"><span data-contrast=\"auto\">Not ready to move to\u00a0<\/span><span data-contrast=\"auto\">a full<\/span><span data-contrast=\"auto\">\u00a0<\/span><span data-contrast=\"auto\">platform-as-a-service<\/span><span data-contrast=\"auto\">\u00a0<\/span><span data-contrast=\"auto\">offer<\/span><span data-contrast=\"auto\">? You<\/span><span data-contrast=\"auto\">\u00a0can take progressive steps to the cloud by migrating<\/span><span data-contrast=\"auto\">\u00a0<\/span><span data-contrast=\"auto\">from\u00a0<\/span><span data-contrast=\"auto\">MongoDB to a\u00a0<\/span><a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/virtual-machines\/windows\/install-mongodb\"><span data-contrast=\"none\"><span data-ccp-charstyle=\"Hyperlink\">Windows VM in Azure<\/span><\/span><\/a><span data-contrast=\"auto\">\u00a0or a\u00a0<\/span><a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/virtual-machines\/linux\/install-mongodb\"><span data-contrast=\"none\"><span data-ccp-charstyle=\"Hyperlink\">Linux VM in Azure<\/span><\/span><\/a><span data-ccp-props=\"{&quot;134233279&quot;:true,&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/li>\n<\/ul>\n<p><strong>Take a closer look: <\/strong><\/p>\n<ul>\n<li>For a more in-depth guide to getting started with Azure Cosmos DB, take a look at this <a href=\"https:\/\/azure.microsoft.com\/en-us\/resources\/developer-s-guide-to-getting-started-with-azure-cosmos-db\/\">e-Book<\/a><\/li>\n<li>Assess the API compatibility by reviewing the <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/cosmos-db\/mongodb-feature-support-36\">detailed list of supported features and syntax<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2>Top 3 Reasons to Consider Azure Cosmos DB and the API for MongoDB<\/h2>\n<table style=\"border-collapse: collapse; width: 100%; height: 483px;\">\n<tbody>\n<tr style=\"height: 27px;\">\n<td style=\"width: 10.3851%; height: 42px; background-color: #0078d4; text-align: center; vertical-align: middle;\" rowspan=\"2\"><span style=\"color: #ffffff;\"><strong><em><span style=\"font-size: 18pt;\">1<\/span><\/em><\/strong><\/span><\/td>\n<th style=\"width: 89.6149%; height: 27px; text-align: center;\" width=\"570\"><strong><em>Fully Managed and Cost-Effective<\/em><\/strong><\/th>\n<\/tr>\n<tr style=\"height: 27px;\">\n<td style=\"width: 89.6149%; height: 27px;\">As a fully-managed database service, Azure Cosmos DB automatically handles all maintenance, patching, and updates, saving you money and time that can be used to focus on application development\/management<\/p>\n<p>Cost-effective options enable you to run workloads without having to plan or manage capacity. The three major features that make this possible are:<\/p>\n<ul>\n<li>Standard provisioned throughput \u2013 for workloads with steady or predictable traffic<\/li>\n<li>Autoscale provisioned throughput \u2013 automatically, transparently, and instantly scales your database to closely match the workload requirements with hourly adjustments<\/li>\n<li>Serverless (in Public Preview) \u2013 supports burstable or infrequent operations, only billing you for resources used for each database operation<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr style=\"height: 27px;\">\n<td style=\"width: 10.3851%; height: 387px; background-color: #ffffff; text-align: center; vertical-align: middle;\" rowspan=\"2\"><em><strong><span style=\"font-size: 18pt;\">2<\/span><\/strong><\/em><\/td>\n<th style=\"width: 89.6149%; height: 27px; text-align: center;\"><strong><em>Fast and Flexible Application Development<\/em><\/strong><\/th>\n<\/tr>\n<tr style=\"height: 360px;\">\n<td style=\"width: 89.6149%; height: 360px;\" width=\"570\">Supports the wire protocols of commonly used NoSQL APIs including MongoDB, which makes it possible to leverage your skillset and easily migrate workloads while preserving significant portions of application logic<\/p>\n<p>Instantaneous automatic scaling that abstracts away all the operational complexity associated with maintaining replicas and shards of your data. Choose a good <a href=\"https:\/\/www.youtube.com\/watch?v=wOWa8ecFo88\">data model<\/a> and an <a href=\"https:\/\/www.youtube.com\/watch?v=277kuTO33yI\">efficient shard [partition] key<\/a>\u00a0and Azure Cosmos DB can limitlessly scale data and throughput<\/p>\n<p>Unlike MongoDB, you choose from five well-defined <a href=\"https:\/\/www.youtube.com\/watch?v=t1--kZjrG-o\">consistency levels<\/a> that provide granular tradeoffs with respect to availability, latency, and throughput<\/p>\n<p>Deeply integrated with key Azure services used in cloud-native application development including Azure Functions, IoT Hub, AKS (Azure Kubernetes Service), App Service, and more<\/p>\n<p>Azure <a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/announce-azure-synapse-link-no-etl-analytics\/\">Synapse Link for Azure Cosmos DB<\/a>, a cloud-native implementation of HTAP, enables near real-time insights over MongoDB data through Synapse Spark or Synapse SQL<\/td>\n<\/tr>\n<tr style=\"height: 27px;\">\n<td style=\"width: 10.3851%; height: 54px; background-color: #50e6ff; text-align: center; vertical-align: middle;\" rowspan=\"2\"><span style=\"font-size: 18pt;\"><em><strong>3<\/strong><\/em><\/span><\/td>\n<th style=\"width: 89.6149%; height: 27px; text-align: center;\"><strong><em>Mission Critical Ready<\/em><\/strong><\/th>\n<\/tr>\n<tr style=\"height: 27px;\">\n<td style=\"width: 89.6149%; height: 27px;\"><a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/cosmos-db\/distribute-data-globally\">Geo-distributed<\/a> with multi-region writes, and active\/active data replication to any Azure region made possible with the click of a button<\/p>\n<p>Industry leading, financially backed <a href=\"https:\/\/azure.microsoft.com\/en-us\/support\/legal\/sla\/cosmos-db\/v1_3\/\">SLAs<\/a> for high availability, throughput, and consistency<\/p>\n<p><a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/cosmos-db\/database-security\">Enterprise-level security<\/a> with encryption-at-rest, access control, and more<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<h2>About Azure Cosmos DB<\/h2>\n<p><a href=\"https:\/\/azure.microsoft.com\/services\/cosmos-db\/\">Azure Cosmos DB<\/a> is a fully managed NoSQL database for modern and cloud-native app development, with SLA-backed speed and availability, automatic and instant scalability, and an open source API for MongoDB (among other APIs).<\/p>\n<p>For more information you can visit <a href=\"http:\/\/azurecosmosdb.com\">http:\/\/azurecosmosdb.com<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how you can benefit by using your MongoDB skills on Azure Cosmos DB with the API for MongoDB. <\/p>\n","protected":false},"author":42942,"featured_media":61,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[15,19],"tags":[],"class_list":["post-1902","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mongodb-api","category-tips-and-tricks"],"acf":[],"blog_post_summary":"<p>Learn how you can benefit by using your MongoDB skills on Azure Cosmos DB with the API for MongoDB. <\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/posts\/1902","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/users\/42942"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/comments?post=1902"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/posts\/1902\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/media\/61"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/media?parent=1902"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/categories?post=1902"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/tags?post=1902"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}