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.
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:
$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
Command
Supported
and
Yes
not
Yes
or
Yes
Set expressions
Command
Supported
setEquals
Yes
setIntersection
Yes
setUnion
Yes
setDifference
Yes
setIsSubset
Yes
anyElementTrue
Yes
allElementsTrue
Yes
Comparison expressions
Note
The API for MongoDB does not support comparison expressions with an array literal in the query.
Command
Supported
cmp
Yes
eq
Yes
gt
Yes
gte
Yes
lt
Yes
lte
Yes
ne
Yes
in
Yes
nin
Yes
Arithmetic expressions
Command
Supported
abs
Yes
add
Yes
ceil
Yes
divide
Yes
exp
Yes
floor
Yes
ln
Yes
log
Yes
log10
Yes
mod
Yes
multiply
Yes
pow
Yes
sqrt
Yes
subtract
Yes
trunc
Yes
String expressions
Command
Supported
concat
Yes
indexOfBytes
Yes
indexOfCP
Yes
split
Yes
strLenBytes
Yes
strLenCP
Yes
strcasecmp
Yes
substr
Yes
substrBytes
Yes
substrCP
Yes
toLower
Yes
toUpper
Yes
Text search operator
Command
Supported
meta
No
Array expressions
Command
Supported
arrayElemAt
Yes
arrayToObject
Yes
concatArrays
Yes
filter
Yes
indexOfArray
Yes
isArray
Yes
objectToArray
Yes
range
Yes
reverseArray
Yes
reduce
Yes
size
Yes
slice
Yes
zip
Yes
in
Yes
Variable operators
Command
Supported
map
Yes
let
Yes
System variables
Command
Supported
$$CURRENT
Yes
$$DESCEND
Yes
$$KEEP
Yes
$$PRUNE
Yes
$$REMOVE
Yes
$$ROOT
Yes
Literal operator
Command
Supported
literal
Yes
Date expressions
Command
Supported
dayOfYear
Yes
dayOfMonth
Yes
dayOfWeek
Yes
year
Yes
month
Yes
week
Yes
hour
Yes
minute
Yes
second
Yes
millisecond
Yes
dateToString
Yes
isoDayOfWeek
Yes
isoWeek
Yes
dateFromParts
Yes
dateToParts
Yes
dateFromString
Yes
isoWeekYear
Yes
Conditional expressions
Command
Supported
cond
Yes
ifNull
Yes
switch
Yes
Data type operator
Command
Supported
type
Yes
Accumulator expressions
Command
Supported
sum
Yes
avg
Yes
first
Yes
last
Yes
max
Yes
min
Yes
push
Yes
addToSet
Yes
stdDevPop
Yes
stdDevSamp
Yes
Merge operator
Command
Supported
mergeObjects
Yes
Data types
Command
Supported
Double
Yes
String
Yes
Object
Yes
Array
Yes
Binary Data
Yes
ObjectId
Yes
Boolean
Yes
Date
Yes
Null
Yes
32-bit Integer (int)
Yes
Timestamp
Yes
64-bit Integer (long)
Yes
MinKey
Yes
MaxKey
Yes
Decimal128
Yes
Regular Expression
Yes
JavaScript
Yes
JavaScript (with scope)
Yes
Undefined
Yes
Indexes and index properties
Indexes
Command
Supported
Single Field Index
Yes
Compound Index
Yes
Multikey Index
Yes
Text Index
No
2dsphere
Yes
2d Index
No
Hashed Index
No
Index properties
Command
Supported
TTL
Yes
Unique
Yes
Partial
No
Case Insensitive
No
Sparse
No
Background
Yes
Operators
Logical operators
Command
Supported
or
Yes
and
Yes
not
Yes
nor
Yes
Element operators
Command
Supported
exists
Yes
type
Yes
Evaluation query operators
Command
Supported
expr
Yes
jsonSchema
No
mod
Yes
regex
Yes
text
No (Not supported. Use $regex instead.)
where
No
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
Command
Supported
all
Yes
elemMatch
Yes
size
Yes
Comment operator
Command
Supported
comment
Yes
Projection operators
Command
Supported
elemMatch
Yes
meta
No
slice
Yes
Update operators
Field update operators
Command
Supported
inc
Yes
mul
Yes
rename
Yes
setOnInsert
Yes
set
Yes
unset
Yes
min
Yes
max
Yes
currentDate
Yes
Array update operators
Command
Supported
$
Yes
$[]
Yes
$[\<identifier\>]
Yes
addToSet
Yes
pop
Yes
pullAll
Yes
pull
Yes
push
Yes
pushAll
Yes
Update modifiers
Command
Supported
each
Yes
slice
Yes
sort
Yes
position
Yes
Bitwise update operator
Command
Supported
bit
Yes
bitsAllSet
No
bitsAnySet
No
bitsAllClear
No
bitsAnyClear
No
Geospatial operators
Operator
Supported
$geoWithin
Yes
$geoIntersects
Yes
$near
Yes
$nearSphere
Yes
$geometry
Yes
$minDistance
Yes
$maxDistance
Yes
$center
No
$centerSphere
No
$box
No
$polygon
No
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 supports MongoDB v4.2, or MongoDB v5.0 for vCore clusters. These versions don't support all the newer features and functionality in the versions of MongoDB available on MongoDB Atlas.
A Definition of Azure Cosmos DB. Cosmos DB is a database service that is globally distributed. It allows you to manage your data even if you keep them in data centers that are scattered throughout the world.
Cosmos DB also does not support time-series data.MongoDB, on the other hand, lets you run key-value, graph, and SQL queries against the same data. And, with MongoDB 5.0, you can build and run applications with support for specific time-series data storage and query patterns.
One of the main weaknesses of Cosmos DB is that users need to be experienced to tune and configure it well. As a result you can end up with a cost over-run of Cosmos DB is not configured properly. Learning Cosmos DB takes time, it is nothing like regular SQL or MS SQL.
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.
Azure Cosmos DB for NoSQL is a native non-relational service for working with the document data model. It can arbitrarily store native JSON documents with flexible schema. Data is indexed automatically and is available for query using a flavor of the SQL query language designed for JSON data.
Items can be queried with a read-only, JSON-friendly SQL dialect. As Cosmos DB embeds a JavaScript engine, the SQL API also enables: Stored procedures. Functions that bundle an arbitrarily complex set of operations and logic into an ACID-compliant transaction.
Azure Cosmos DB supports flexible schemas and hierarchical data, and thus it is well suited for storing product catalog data. Azure Cosmos DB is often used for event sourcing to power event driven architectures using its change feed functionality.
The APIs for a subset of models are available using the ARS design (MongoDB RU, NoSQL, Table, Apache Cassandra, and Apache Gremlin). Azure Cosmos DB also supports other APIs such as MongoDB vCore, Cassandra MI, or PostgreSQL.
In Azure Cosmos DB for NoSQL, data is schema-free and typically denormalized. Instead of joining data across entities and sets, like you would in a relational database, joins occur within a single item. Specifically, joins are scoped to that item and can't occur across multiple items and containers.
MongoDB has two Kotlin drivers: the Kotlin Coroutine Driver for Kotlin applications using coroutines, and the Kotlin Sync Driver for synchronous Kotlin applications. This makes MongoDB a popular NoSQL database for Kotlin.
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.
Azure Cosmos DB for NoSQL offers comprehensive SLAs across throughput, latency, consistency, and high availability for NoSQL data. This includes less than 10 millisecond write-and-read latency and 99.999 percent availability. Azure Cosmos DB for PostgreSQL offers 99.95 percent availability.
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. Users and roles reside within a database and are managed using the Azure CLI, Azure PowerShell, or Azure Resource Manager (ARM).
Address: 5789 Michel Vista, West Domenic, OR 80464-9452
Phone: +97313824072371
Job: Education Orchestrator
Hobby: Lockpicking, Crocheting, Baton twirling, Video gaming, Jogging, Whittling, Model building
Introduction: My name is Rob Wisoky, I am a smiling, helpful, encouraging, zealous, energetic, faithful, fantastic person who loves writing and wants to share my knowledge and understanding with you.
We notice you're using an ad blocker
Without advertising income, we can't keep making this site awesome for you.