MongoDB compatibility and feature support with Azure Cosmos DB for MongoDB vCore
APPLIES TO: MongoDB vCore
Azure Cosmos DB for MongoDB vCore allows you to experience the familiar MongoDB advantages while accessing the enhanced enterprise features offered by Azure Cosmos DB. It ensures compatibility by following the MongoDB wire protocol, allowing you to leverage existing client drivers, SDKs and other tools you're already familiar with.
Protocol support
The supported operators and any limitations or exceptions are listed here. Any client driver that understands these protocols should be able to connect to Azure Cosmos DB for MongoDB. When you create Azure Cosmos DB for MongoDB vCore clusters, the endpoint is in the format *.mongocluster.cosmos.azure.com
.
Query language support
Azure Cosmos DB for MongoDB provides comprehensive support for MongoDB query language constructs. Below you can find the detailed list of currently supported database commands, operators, stages, and options.
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 the Azure Cosmos DB for MongoDB.
Database commands
Azure Cosmos DB for MongoDB vCore supports the following database commands:
Category | Command | Supported |
Aggregation Commands | aggregate | Yes |
count | Yes | |
distinct | Yes | |
mapReduce | Deprecated | |
Authentication Commands | authenticate | Yes |
getnonce | Yes | |
logout | Yes | |
Geospatial Commands | geoSearch | Deprecated |
Query Plan Cache Commands | No | |
Administrative Commands | cloneCollectionAsCapped | No. Capped collections are currently not supported. |
collMod | Partial | |
compact | No | |
connPoolSync | Deprecated | |
convertToCapped | No. Capped collections are currently not supported. | |
create | Partial | |
createIndexes | Yes | |
currentOp | Yes | |
drop | Yes | |
dropDatabase | Yes | |
dropConnections | As a PaaS service, this will be managed by Azure. | |
dropIndexes | Yes | |
filemd5 | No | |
fsync | As a PaaS service, this will be managed by Azure. | |
fsyncUnlock | As a PaaS service, this will be managed by Azure. | |
getDefaultRWConcern | Yes | |
getClusterParameter | No | |
getParameter | Yes | |
killCursors | Yes | |
killOp | Yes | |
listCollections | Yes | |
listDatabases | Yes | |
listIndexes | Yes | |
logRotate | As a PaaS service, this will be managed by Azure. | |
reIndex | Yes | |
renameCollection | Yes | |
rotateCertificates | As a PaaS service, this will be managed by Azure. | |
setFeatureCompatibilityVersion | As a PaaS service, this will be managed by Azure. | |
setIndexCommitQuorum | No | |
setParameter | Partial | |
setDefaultRWConcern | No | |
shutdown | As a PaaS service, this will be managed by Azure. | |
User & Role Management Commands | Not supported today, but will be made available through Azure Active Directory in the future. | |
Replication Commands | Azure manages replication, removing the necessity for customers to replicate manually. | |
Sharding Commands | enableSharding | Yes |
isdbgrid | Yes | |
reshardCollection | Yes | |
shardCollection | Yes | |
unsetSharding | Deprecated | |
addShard | As a Platform-as-a-Service (PaaS) offering, Azure manages shard management and rebalancing. Users only need to specify the sharding strategy for the collections and Azure will handle the rest. | |
addShardToZone | ||
clearJumboFlag | ||
cleanupOrphaned | ||
removeShard | ||
removeShardFromZone | ||
setShardVersion | ||
mergeChunks | ||
checkShardingIndex | ||
getShardMap | ||
getShardVersion | ||
medianKey | ||
splitVector | ||
shardingState | ||
cleanupReshardCollection | ||
flushRouterConfig | ||
balancerCollectionStatus | ||
balancerStart | ||
balancerStatus | ||
balancerStop | ||
configureCollectionBalancing | ||
listShards | ||
split | ||
moveChunk | ||
updateZoneKeyRange | ||
movePrimary | ||
abortReshardCollection | ||
commitReshardCollection | ||
refineCollectionShardKey | ||
reshardCollection | No | |
Query and Write Operation Commands | change streams | No |
delete | Yes | |
find | Yes | |
findAndModify | Yes | |
getLastError | Yes | |
getMore | Partial | |
insert | Yes | |
resetError | Deprecated | |
update | Yes | |
Session Commands | abortTransaction | Yes |
commitTransaction | Yes | |
endSessions | Yes | |
killAllSessions | No | |
killAllSessionsByPattern | No | |
killSessions | Yes | |
refreshSessions | No | |
startSession | Yes | |
Diagnostic Commands | availableQueryOptions | No |
buildInfo | Yes | |
collStats | Yes | |
connPoolStats | No | |
connectionStatus | Partial | |
dataSize | No | |
dbHash | No | |
dbStats | No | |
driverOIDTest | As a PaaS service, this will be managed by Azure. | |
explain | Yes | |
features | As a PaaS service, this will be managed by Azure. | |
getCmdLineOpts | Yes | |
getLog | Yes | |
hostInfo | Partial | |
_isSelf | No | |
listCommands | Yes | |
lockInfo | No | |
netstat | No | |
ping | Yes | |
profile | As a PaaS service, this will be managed by Azure. | |
serverStatus | Yes | |
shardConnPoolStats | Deprecated | |
top | No | |
validate | Yes | |
whatsmyuri | Yes | |
System Events Auditing Commands | logApplicationMessage | No |
Operators
Below are the list of operators currently supported on Azure Cosmos DB for MongoDB vCore:
Note
The $lookup
aggregation does not yet support using variable expressions using 'let'.
AvgObjsize and size in "collStats" works with document size less than 2KB only.
Category | Operator | Supported |
Comparison Query Operators | $eq | Yes |
$gt | Yes | |
$gte | Yes | |
$in | Yes | |
$lt | Yes | |
$lte | Yes | |
$ne | Yes | |
$nin | Yes | |
Logical Query Operators | $and | Yes |
$not | Yes | |
$nor | Yes | |
$or | Yes | |
Element Query Operators | $exists | Yes |
$type | Yes | |
Evaluation Query Operators | $expr | Yes |
$jsonSchema | No | |
$mod | Yes | |
$regex | Yes | |
$text | Yes | |
$where | No | |
Geospatial Operators | In Private Preview* | |
Array Query Operators | $all | Yes |
$elemMatch | Yes | |
$size | Yes | |
Bitwise Query Operators | $bitsAllClear | Yes |
$bitsAllSet | Yes | |
$bitsAnyClear | Yes | |
$bitsAnySet | Yes | |
Projection Operators | $ | Yes |
$elemMatch | Yes | |
$meta | Yes | |
$slice | Yes | |
Miscellaneous Query Operators | $comment | No |
$rand | Yes | |
$natural | No | |
Field Update Operators | $currentDate | Yes |
$inc | Yes | |
$min | Yes | |
$max | Yes | |
$mul | Yes | |
$rename | Yes | |
$set | Yes | |
$setOnInsert | Yes | |
$unset | Yes | |
Array Update Operators | $ | Yes |
$[] | Yes | |
$[identifier] | Yes | |
$addToSet | Yes | |
$pop | Yes | |
$pull | Yes | |
$push | Yes | |
$pullAll | Yes | |
$each | Yes | |
$position | Yes | |
$slice | Yes | |
$sort | Yes | |
Bitwise Update Operators | $bit | Yes |
Arithmetic Expression Operators | $abs | Yes |
$add | Yes | |
$ceil | Yes | |
$divide | Yes | |
$exp | Yes | |
$floor | Yes | |
$ln | Yes | |
$log | Yes | |
$log10 | Yes | |
$mod | Yes | |
$multiply | Yes | |
$pow | Yes | |
$round | Yes | |
$sqrt | Yes | |
$subtract | Yes | |
$trunc | Yes | |
Array Expression Operators | $arrayElemAt | Yes |
$arrayToObject | Yes | |
$concatArrays | Yes | |
$filter | Yes | |
$firstN | Yes | |
$in | Yes | |
$indexOfArray | Yes | |
$isArray | Yes | |
$lastN | Yes | |
$map | No | |
$maxN | No | |
$minN | No | |
$objectToArray | Yes | |
$range | Yes | |
$reduce | No | |
$reverseArray | Yes | |
$size | Yes | |
$slice | Yes | |
$sortArray | No | |
$zip | No | |
Bitwise Operators | $bitAnd | Yes |
$bitNot | Yes | |
$bitOr | Yes | |
$bitXor | Yes | |
Boolean Expression Operators | $and | Yes |
$not | Yes | |
$or | Yes | |
Comparison Expression Operators | $cmp | Yes |
$eq | Yes | |
$gt | Yes | |
$gte | Yes | |
$lt | Yes | |
$lte | Yes | |
$ne | Yes | |
Custom Aggregation Expression Operators | Not supported. | |
Data Size Operators | $bsonSize | Yes |
$binarySize | Yes | |
Date Expression Operators | $dateAdd | No |
$dateDiff | No | |
$dateFromParts | No | |
$dateFromString | No | |
$dateSubtract | No | |
$dateToParts | Yes | |
$dateToString | Yes | |
$dateTrunc | No | |
$dayOfMonth | Yes | |
$dayOfWeek | Yes | |
$dayOfYear | Yes | |
$hour | Yes | |
$isoDayOfWeek | Yes | |
$isoWeek | Yes | |
$isoWeekYear | Yes | |
$millisecond | Yes | |
$minute | Yes | |
$month | Yes | |
$second | Yes | |
$toDate | Yes | |
$week | Yes | |
$year | Yes | |
Literal Expression Operator | $literal | Yes |
Miscellaneous Operators | $getField | No |
$rand | Yes | |
$sampleRate | No | |
Object Expression Operators | $mergeObjects | Yes |
$objectToArray | Yes | |
$setField | Yes | |
Set Expression Operators | $allElementsTrue | Yes |
$anyElementTrue | Yes | |
$setDifference | Yes | |
$setEquals | Yes | |
$setIntersection | Yes | |
$setIsSubset | Yes | |
$setUnion | Yes | |
String Expression Operators | $concat | Yes |
$dateFromString | No | |
$dateToString | Yes | |
$indexOfBytes | Yes | |
$indexOfCP | Yes | |
$ltrim | Yes | |
$regexFind | Yes | |
$regexFindAll | Yes | |
$regexMatch | Yes | |
$replaceOne | Yes | |
$replaceAll | Yes | |
$rtrim | Yes | |
$split | Yes | |
$strLenBytes | Yes | |
$strLenCP | Yes | |
$strcasecmp | Yes | |
$substr | Yes | |
$substrBytes | Yes | |
$substrCP | Yes | |
$toLower | Yes | |
$toString | Yes | |
$trim | Yes | |
$toUpper | Yes | |
Text Expression Operator | $meta | Yes |
Timestamp Expression Operators | Not supported. | |
Trigonometry Expression Operators | Not supported. | |
Type Expression Operators | $convert | Yes |
$isNumber | Yes | |
$toBool | Yes | |
$toDate | Yes | |
$toDecimal | Yes | |
$toDouble | Yes | |
$toInt | Yes | |
$toLong | Yes | |
$toObjectId | Yes | |
$toString | Yes | |
$type | Yes | |
Accumulators ($group, $bucket, $bucketAuto, $setWindowFields) | $accumulator | No |
$addToSet | No | |
$avg | Yes | |
$bottom | No | |
$bottomN | No | |
$count /td> | Yes | |
$first | Yes | |
$firstN | Yes | |
$last | Yes | |
$lastN | Yes | |
$max | Yes | |
$maxN | No | |
$median | No | |
$mergeObjects | No | |
$min | Yes | |
$percentile | No | |
$push | No | |
$stdDevPop | No | |
$stdDevSamp | No | |
$sum | Yes | |
$top | No | |
$topN | No | |
Accumulators (in Other Stages) | $avg | No |
$first | Yes | |
$last | Yes | |
$max | No | |
$median | No | |
$min | No | |
$percentile | No | |
$stdDevPop | No | |
$stdDevSamp | No | |
$sum | No | |
Variable Expression Operators | Not supported. | |
Window Operators | Not supported. | |
Conditional Expression Operators | $cond | Yes |
$ifNull | Yes | |
$switch | Yes | |
Aggregation Pipeline Stages | $addFields | Yes |
$bucket | No | |
$bucketAuto | No | |
$changeStream | No | |
$changeStreamSplitLargeEvent | No | |
$collStats | Yes | |
$count | Yes | |
$densify | No | |
$documents | No | |
$facet | Yes | |
$fill | No | |
$geoNear | No | |
$graphLookup | Yes | |
$group | Yes | |
$indexStats | Yes | |
$limit | Yes | |
$listSampledQueries | No | |
$listSearchIndexes | No | |
$listSessions | No | |
$lookup | Yes | |
$match | Yes | |
$merge | No | |
$out | No | |
$planCacheStats | No | |
$project | Yes | |
$redact | No | |
$replaceRoot | Yes | |
$replaceWith | Yes | |
$sample | Yes | |
$search | Yes | |
$searchMeta | Yes | |
$set | Yes | |
$setWindowFields | No | |
$skip | Yes | |
$sort | Yes | |
$sortByCount | Yes | |
$unionWith | No | |
$unset | Yes | |
$unwind | Yes | |
$shardedDataDistribution | No | |
$changeStream | No | |
$currentOp | Yes | |
$listLocalSessions | No | |
$documents | No |
Indexes and index properties
Azure Cosmos DB for MongoDB vCore supports the following indexes and index properties:
Note
Creating a unique index obtains an exclusive lock on the collection for the entire duration of the build process. This blocks read and write operations on the collection until the operation is completed.
Indexes
Command | Supported |
Single Field Index | Yes |
Compound Index | Yes |
Multikey Index | Yes |
Text Index | Yes |
Geospatial Index | In Private Preview* |
Hashed Index | Yes |
Vector Index (only available in Cosmos DB) | Yes, with vector search |
Index properties
Command | Supported |
TTL | Yes |
Unique | Yes |
Partial | Yes |
Case Insensitive | No |
Sparse | Yes |
Background | Yes |
Next steps
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for