Azure Cosmos DB for MongoDB (3.6 version) supported features and syntax (2024)

  • Article

APPLIES TO:Azure Cosmos DB for MongoDB (3.6 version) supported features and syntax (1)MongoDB

Azure Cosmos DB is Microsoft's globally distributed multi-model database service. You can communicate with the Azure Cosmos DB for MongoDB using any of the open-source MongoDB client drivers. The Azure Cosmos DB for MongoDB enables the use of existing client drivers by adhering to the MongoDB wire protocol.

By using the Azure Cosmos DB for MongoDB, you can enjoy the benefits of the MongoDB you're used to, with all of the enterprise capabilities that Azure Cosmos DB provides: global distribution, automatic sharding, availability and latency guarantees, encryption at rest, backups, and much more.

Note

Version 3.6 of the Azure Cosmos DB for MongoDB has no current plans for end-of-life (EOL). The minimum notice for a future EOL is three years.

Protocol Support

The Azure Cosmos DB for MongoDB is compatible with MongoDB server version 3.6 by default for new accounts. The supported operators and any limitations or exceptions are listed below. Any client driver that understands these protocols should be able to connect to Azure Cosmos DB for MongoDB. When you create Azure Cosmos DB API for MongoDB accounts, the 3.6 version of account has the endpoint in the format *.mongo.cosmos.azure.com whereas the 3.2 version of account has the endpoint in the format *.documents.azure.com.

Query language support

Azure Cosmos DB for MongoDB provides comprehensive support for MongoDB query language constructs. The following sections show the detailed list of server operations, operators, stages, commands, and options currently supported by Azure Cosmos DB.

Note

This article only lists the supported server commands and excludes client-side wrapper functions. Client-side wrapper functions such as deleteMany() and updateMany() internally utilize the delete() and update() server commands. Functions utilizing supported server commands are compatible with Azure Cosmos DB for MongoDB.

Database commands

Azure Cosmos DB for MongoDB supports the following database commands:

Query and write operation commands

CommandSupported
change streamsYes
deleteYes
evalNo
findYes
findAndModifyYes
getLastErrorYes
getMoreYes
getPrevErrorNo
insertYes
parallelCollectionScanNo
resetErrorNo
updateYes

Authentication commands

CommandSupported
authenticateYes
getnonceYes
logoutYes

Administration commands

CommandSupported
cloneCollectionAsCappedNo
collModNo
connectionStatusNo
convertToCappedNo
copydbNo
createYes
createIndexesYes
currentOpYes
dropYes
dropDatabaseYes
dropIndexesYes
filemd5Yes
killCursorsYes
killOpNo
listCollectionsYes
listDatabasesYes
listIndexesYes
reIndexYes
renameCollectionNo

Diagnostics commands

CommandSupported
buildInfoYes
collStatsYes
connPoolStatsNo
connectionStatusNo
dataSizeNo
dbHashNo
dbStatsYes
explainYes
featuresNo
hostInfoYes
listDatabasesYes
listCommandsNo
profilerNo
serverStatusNo
topNo
whatsmyuriYes

Aggregation pipeline

Aggregation commands

CommandSupported
aggregateYes
countYes
distinctYes
mapReduceNo

Aggregation stages

CommandSupported
addFieldsYes
bucketNo
bucketAutoNo
changeStreamYes
collStatsNo
countYes
currentOpNo
facetYes
geoNearYes
graphLookupYes
groupYes
indexStatsNo
limitYes
listLocalSessionsNo
listSessionsNo
lookupPartial
matchYes
outYes
projectYes
redactYes
replaceRootYes
replaceWithNo
sampleYes
skipYes
sortYes
sortByCountYes
unwindYes

Note

$lookup does not yet support the uncorrelated subqueries feature introduced in server version 3.6. You will receive an error with a message containing let is not supported if you attempt to use the $lookup operator with let and pipeline fields.

Boolean expressions

CommandSupported
andYes
notYes
orYes

Set expressions

CommandSupported
setEqualsYes
setIntersectionYes
setUnionYes
setDifferenceYes
setIsSubsetYes
anyElementTrueYes
allElementsTrueYes

Comparison expressions

Note

The API for MongoDB does not support comparison expressions with an array literal in the query.

CommandSupported
cmpYes
eqYes
gtYes
gteYes
ltYes
lteYes
neYes
inYes
ninYes

Arithmetic expressions

CommandSupported
absYes
addYes
ceilYes
divideYes
expYes
floorYes
lnYes
logYes
log10Yes
modYes
multiplyYes
powYes
sqrtYes
subtractYes
truncYes

String expressions

CommandSupported
concatYes
indexOfBytesYes
indexOfCPYes
splitYes
strLenBytesYes
strLenCPYes
strcasecmpYes
substrYes
substrBytesYes
substrCPYes
toLowerYes
toUpperYes

Text search operator

CommandSupported
metaNo

Array expressions

CommandSupported
arrayElemAtYes
arrayToObjectYes
concatArraysYes
filterYes
indexOfArrayYes
isArrayYes
objectToArrayYes
rangeYes
reverseArrayYes
reduceYes
sizeYes
sliceYes
zipYes
inYes

Variable operators

CommandSupported
mapYes
letYes

System variables

CommandSupported
$$CURRENTYes
$$DESCENDYes
$$KEEPYes
$$PRUNEYes
$$REMOVEYes
$$ROOTYes

Literal operator

CommandSupported
literalYes

Date expressions

CommandSupported
dayOfYearYes
dayOfMonthYes
dayOfWeekYes
yearYes
monthYes
weekYes
hourYes
minuteYes
secondYes
millisecondYes
dateToStringYes
isoDayOfWeekYes
isoWeekYes
dateFromPartsYes
dateToPartsYes
dateFromStringYes
isoWeekYearYes

Conditional expressions

CommandSupported
condYes
ifNullYes
switchYes

Data type operator

CommandSupported
typeYes

Accumulator expressions

CommandSupported
sumYes
avgYes
firstYes
lastYes
maxYes
minYes
pushYes
addToSetYes
stdDevPopYes
stdDevSampYes

Merge operator

CommandSupported
mergeObjectsYes

Data types

CommandSupported
DoubleYes
StringYes
ObjectYes
ArrayYes
Binary DataYes
ObjectIdYes
BooleanYes
DateYes
NullYes
32-bit Integer (int)Yes
TimestampYes
64-bit Integer (long)Yes
MinKeyYes
MaxKeyYes
Decimal128Yes
Regular ExpressionYes
JavaScriptYes
JavaScript (with scope)Yes
UndefinedYes

Indexes and index properties

Indexes

CommandSupported
Single Field IndexYes
Compound IndexYes
Multikey IndexYes
Text IndexNo
2dsphereYes
2d IndexNo
Hashed IndexNo

Index properties

CommandSupported
TTLYes
UniqueYes
PartialNo
Case InsensitiveNo
SparseNo
BackgroundYes

Operators

Logical operators

CommandSupported
orYes
andYes
notYes
norYes

Element operators

CommandSupported
existsYes
typeYes

Evaluation query operators

CommandSupported
exprYes
jsonSchemaNo
modYes
regexYes
textNo (Not supported. Use $regex instead.)
whereNo

In the $regex queries, left-anchored expressions allow index search. However, using 'i' modifier (case-insensitivity) and 'm' modifier (multiline) causes the collection scan in all expressions.

When there's a need to include $ or |, it's best to create two (or more) regex queries. For example, given the following original query: find({x:{$regex: /^abc$/}), it has to be modified as follows:

find({x:{$regex: /^abc/, x:{$regex:/^abc$/}})

The first part will use the index to restrict the search to those documents beginning with ^abc and the second part will match the exact entries. The bar operator | acts as an "or" function - the query find({x:{$regex: /^abc |^def/}) matches the documents in which field x has values that begin with "abc" or "def". To utilize the index, it's recommended to break the query into two different queries joined by the $or operator: find( {$or : [{x: $regex: /^abc/}, {$regex: /^def/}] }).

Array operators

CommandSupported
allYes
elemMatchYes
sizeYes

Comment operator

CommandSupported
commentYes

Projection operators

CommandSupported
elemMatchYes
metaNo
sliceYes

Update operators

Field update operators

CommandSupported
incYes
mulYes
renameYes
setOnInsertYes
setYes
unsetYes
minYes
maxYes
currentDateYes

Array update operators

CommandSupported
$Yes
$[]Yes
$[\<identifier\>]Yes
addToSetYes
popYes
pullAllYes
pullYes
pushYes
pushAllYes

Update modifiers

CommandSupported
eachYes
sliceYes
sortYes
positionYes

Bitwise update operator

CommandSupported
bitYes
bitsAllSetNo
bitsAnySetNo
bitsAllClearNo
bitsAnyClearNo

Geospatial operators

OperatorSupported
$geoWithinYes
$geoIntersectsYes
$nearYes
$nearSphereYes
$geometryYes
$minDistanceYes
$maxDistanceYes
$centerNo
$centerSphereNo
$boxNo
$polygonNo

Sort operations

When you use the findOneAndUpdate operation, sort operations on a single field are supported, but sort operations on multiple fields aren't supported.

Indexing

The API for MongoDB supports various indexes to enable sorting on multiple fields, improve query performance, and enforce uniqueness.

GridFS

Azure Cosmos DB supports GridFS through any GridFS-compatible MongoDB driver.

Replication

Azure Cosmos DB supports automatic, native replication at the lowest layers. This logic is extended out to achieve low-latency, global replication as well. Azure Cosmos DB doesn't support manual replication commands.

Retryable Writes

Azure Cosmos DB doesn't yet support retryable writes. Client drivers must add retryWrites=false to their connection string.

Sharding

Azure Cosmos DB supports automatic, server-side sharding. It manages shard creation, placement, and balancing automatically. Azure Cosmos DB doesn't support manual sharding commands, which means you don't have to invoke commands such as addShard, balancerStart, moveChunk etc. You only need to specify the shard key while creating the containers or querying the data.

Sessions

Azure Cosmos DB doesn't yet support server-side sessions commands.

Time-to-live (TTL)

Azure Cosmos DB supports a time-to-live (TTL) based on the timestamp of the document. TTL can be enabled for collections from the Azure portal.

User and role management

Azure Cosmos DB doesn't yet support users and roles. However, it supports Azure role-based access control (Azure RBAC) and read-write and read-only passwords or keys that can be obtained through the connection string pane in the Azure portal.

Write Concern

Some applications rely on a Write Concern, which specifies the number of responses required during a write operation. Due to how Azure Cosmos DB handles replication, all writes are automatically majority quorum by default when using strong consistency. Any write concern specified by the client code is ignored. To learn more, see Using consistency levels to maximize availability and performance article.

Next steps

  • For further information check Mongo 3.6 version features
  • Learn how to use Studio 3T with Azure Cosmos DB for MongoDB.
  • Learn how to use Robo 3T with Azure Cosmos DB for MongoDB.
  • Explore MongoDB samples with Azure Cosmos DB for MongoDB.
Azure Cosmos DB for MongoDB (3.6 version) supported features and syntax (2024)

FAQs

What are the features of Cosmos DB for MongoDB? ›

Security Controls
MongoDBMicrosoft Cosmos DB Emulation API
Encryption of data at-restYesYes
Client-side field level encryption Encryption of data in-use. Data not readable by service providerYesNo
Queryable Encryption Data encrypted on the client side can be queried without decryption.YesNo
LDAP IntegrationYesYes
5 more rows

What is the difference between Cosmos DB and Cosmos DB for MongoDB? ›

MongoDB is strictly a document-based NoSQL database. However, it allows you to run queries against your data as if it is a SQL, key-value, or graph store, whereas Cosmos DB only allows you to run queries of the same type as the data you created.

What is Azure Cosmos DB and what are its features? ›

Azure Cosmos DB is a global distributed, multi-model database that is used in a wide range of applications and use cases. It is a good choice for any serverless application that needs low order-of-millisecond response times, and needs to scale rapidly and globally.

Is Cosmos DB MongoDB compatible? ›

As of October 2023, Azure Cosmos DB is about 32 percent compatible with the MongoDB API.

What are the main features of MongoDB? ›

Let's take a look at MongoDB's top five technical features:
  • Ad-hoc queries for optimized, real-time analytics. ...
  • Indexing appropriately for better query executions. ...
  • Replication for better data availability and stability. ...
  • Sharding. ...
  • Load balancing.

What is the difference between Azure DB and Cosmos DB? ›

Azure SQL is based on SQL Server engine, you can easily migrate applications and continue to use the tools, languages, and resources that you're familiar with. Azure Cosmos DB is used for web, mobile, gaming, and IoT application that needs to handle massive amounts of data, reads, and writes at a global scale.

Is MongoDB cheaper than Cosmos DB? ›

MongoDB offers more flexibility in terms of setup. It runs on-prem, any cloud provider (Google Cloud Platform, AWS, Azure and more). We found Azure Cosmos DB to be 93% cheaper for reads and around 20% cheaper for writes than MongoDB Atlas depending on workload characteristics (see TCO table below).

What are the disadvantages of Cosmos DB? ›

Cost: Azure Cosmos DB can be expensive, especially for high-performance and high-throughput use cases. SDK complexity: The JavaScript/Frontend SDK for Azure Cosmos DB has a steep learning curve, requiring a good understanding of NoSQL databases and document-oriented storage.

What are the advantages of Cosmos DB? ›

Guarantee business continuity, 99.999% availability, and enterprise-level security for every application.
  • Azure Cosmos DB offers a comprehensive suite of SLAs including industry-leading availability worldwide.
  • Easily distribute data to any Azure region with automatic data replication.
Aug 14, 2024

What are the special features of cosmos? ›

Cosmos features basket-shaped flowerheads that fit perfectly into a cottage garden.
  • The summer flowering Cosmos comes in a wide variety of colours.
  • The variety Cosmos astrosanguineus smells like chocolate.
  • Cosmos is a bee-friendly plant with an abundance of nectar and pollen.

What are the different types of Cosmos DB? ›

Azure Cosmos DB offers multiple database APIs, which include NoSQL, MongoDB, PostgreSQL, Cassandra, Gremlin, and Table. By using these APIs, you can model real world data using documents, key-value, graph, and column-family data models.

What are the requirements for Azure Cosmos DB? ›

An Azure Cosmos DB container (or shared throughput database) using manual throughput must have a minimum throughput of 400 RU/s. As the container grows, Azure Cosmos DB requires a minimum throughput to ensure the resource (database or container) has sufficient resource for its operations.

How to connect Azure Cosmos DB for MongoDB? ›

Follow the below steps:
  1. In an Internet browser, sign in to the Azure portal.
  2. In the Azure Cosmos DB pane, select the API.
  3. In the left pane of the account pane, select Quick start.
  4. Choose your platform (. NET, Node. js, MongoDB Shell, Java, Python). ...
  5. Copy and paste the code snippet into your MongoDB app.

Is MongoDB supported by Azure? ›

MongoDB Atlas is available in 40+ Azure regions. Seamlessly add MongoDB Atlas to existing architectures via integrations with Power Apps, Power BI, Azure Synapse Analytics, and Microsoft Purview.

What is Azure Cosmos DB for MongoDB RBAC? ›

Azure Cosmos DB for MongoDB exposes a built-in role-based access control (RBAC) system that lets you authorize your data requests with a fine-grained, role-based permission model.

What is Azure Cosmos DB for MongoDB RU? ›

Azure Cosmos DB is a fully managed NoSQL, relational, and vector database for modern app development. Both, the Request Unit (RU) and vCore-based Azure Cosmos DB for MongoDB offering make it easy to use Azure Cosmos DB as if it were a MongoDB database.

What features are uniquely available in MongoDB Atlas? ›

MongoDB Atlas
Multi-statement distributed ACID transactionsYes
Integrated text search, geospatial processing, graph traversalsYes All available from a single API and platform
Native support for time series dataYes
Hedged Reads Queries submitted to multiple replicas for consistent low latencyYes
20 more rows

Top Articles
DeSantis vetoes bill to improve public warnings about bacteria contaminating beaches, public waterways
Grace Charis Butt
Funny Roblox Id Codes 2023
Golden Abyss - Chapter 5 - Lunar_Angel
Www.paystubportal.com/7-11 Login
Joi Databas
DPhil Research - List of thesis titles
Shs Games 1V1 Lol
Evil Dead Rise Showtimes Near Massena Movieplex
Steamy Afternoon With Handsome Fernando
Which aspects are important in sales |#1 Prospection
Detroit Lions 50 50
18443168434
Newgate Honda
Zürich Stadion Letzigrund detailed interactive seating plan with seat & row numbers | Sitzplan Saalplan with Sitzplatz & Reihen Nummerierung
Grace Caroline Deepfake
978-0137606801
Nwi Arrests Lake County
Justified Official Series Trailer
London Ups Store
Committees Of Correspondence | Encyclopedia.com
Pizza Hut In Dinuba
Jinx Chapter 24: Release Date, Spoilers & Where To Read - OtakuKart
How Much You Should Be Tipping For Beauty Services - American Beauty Institute
Free Online Games on CrazyGames | Play Now!
Sizewise Stat Login
VERHUURD: Barentszstraat 12 in 'S-Gravenhage 2518 XG: Woonhuis.
Jet Ski Rental Conneaut Lake Pa
Unforeseen Drama: The Tower of Terror’s Mysterious Closure at Walt Disney World
Ups Print Store Near Me
C&T Wok Menu - Morrisville, NC Restaurant
How Taraswrld Leaks Exposed the Dark Side of TikTok Fame
University Of Michigan Paging System
Random Bibleizer
10 Best Places to Go and Things to Know for a Trip to the Hickory M...
Black Lion Backpack And Glider Voucher
Gopher Carts Pensacola Beach
Duke University Transcript Request
Lincoln Financial Field, section 110, row 4, home of Philadelphia Eagles, Temple Owls, page 1
Jambus - Definition, Beispiele, Merkmale, Wirkung
Ark Unlock All Skins Command
Craigslist Red Wing Mn
D3 Boards
Jail View Sumter
Nancy Pazelt Obituary
Birmingham City Schools Clever Login
Thotsbook Com
Funkin' on the Heights
Vci Classified Paducah
Www Pig11 Net
Ty Glass Sentenced
Latest Posts
Article information

Author: Annamae Dooley

Last Updated:

Views: 6140

Rating: 4.4 / 5 (65 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Annamae Dooley

Birthday: 2001-07-26

Address: 9687 Tambra Meadow, Bradleyhaven, TN 53219

Phone: +9316045904039

Job: Future Coordinator

Hobby: Archery, Couponing, Poi, Kite flying, Knitting, Rappelling, Baseball

Introduction: My name is Annamae Dooley, I am a witty, quaint, lovely, clever, rich, sparkling, powerful person who loves writing and wants to share my knowledge and understanding with you.