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:

CategoryCommandFeature
v5.0v6.0v7.0
Aggregation CommandsaggregateYesYesYes
countYesYesYes
distinctYesYesYes
mapReduceDeprecated in MongoDB 5.0
Authentication CommandsauthenticateYesYesYes
getnonceYesYesYes
logoutYesYesYes
Geospatial CommandsgeoSearchDeprecated in MongoDB 5.0
Query Plan Cache CommandsNoNoNo
Administrative CommandscloneCollectionAsCappedNoNo, capped collections are currently not supported.
collModYesYesYes
compactNoNoNo
convertToCappedNoNo. Capped collections are currently not supported.
createYesYesYes
createIndexesYesYesYes
currentOpYesYesYes
dropYesYesYes
dropDatabaseYesYesYes
dropConnectionsAs a PaaS service, this will be managed by Azure.
dropIndexesYesYesYes
filemd5NoNoNo
fsyncAs a PaaS service, this will be managed by Azure.
fsyncUnlockAs a PaaS service, this will be managed by Azure.
getDefaultRWConcernYesYesYes
getClusterParameterNoNo
getParameterYesYesYes
killCursorsYesYesYes
killOpYesYesYes
listCollectionsYesYesYes
listDatabasesYesYesYes
listIndexesYesYesYes
logRotateAs a PaaS service, this will be managed by Azure.
reIndexYesYesYes
renameCollectionYesYesYes
rotateCertificatesAs a PaaS service, this will be managed by Azure.
setFeatureCompatibilityVersionAs a PaaS service, this will be managed by Azure.
setIndexCommitQuorumNoNoNo
setParameterYesYesYes
setDefaultRWConcernNoNoNo
shutdownAs a PaaS service, this will be managed by Azure.
User & Role Management CommandsNot supported today, but will be made available through Azure Active Directory in the future.
Replication CommandsAzure manages replication, removing the necessity for customers to replicate manually.
Sharding CommandsenableShardingYesYesYes
isdbgridYesYesYes
reshardCollectionYesYesYes
shardCollectionYesYesYes
unsetShardingDeprecated in MongoDB 5.0
addShardAs 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
Query and Write Operation Commandschange streamsNoNoNo
deleteYesYesYes
findYesYesYes
findAndModifyYesYesYes
getLastErrorYesYesYes
getMoreYesYesYes
insertYesYesYes
resetErrorDeprecated in MongoDB 5.0
updateYesYesYes
Session CommandsabortTransactionYesYesYes
commitTransactionYesYesYes
endSessionsYesYesYes
killAllSessionsNoNoNo
killAllSessionsByPatternNoNoNo
killSessionsYesYesYes
refreshSessionsNoNoNo
startSessionYesYesYes
Diagnostic CommandsavailableQueryOptionsNoNoNo
buildInfoYesYesYes
collStatsYesYesYes
connPoolStatsNoNoNo
connectionStatusYesYesYes
dataSizeNoNoNo
dbHashNoNoNo
dbStatsYesYesYes
driverOIDTestAs a PaaS service, this will be managed by Azure.
explainYesYesYes
featuresAs a PaaS service, this will be managed by Azure.
getCmdLineOptsYesYesYes
getLogYesYesYes
hostInfoYesYesYes
_isSelfNoNoNo
listCommandsYesYesYes
lockInfoNoNoNo
netstatNoNoNo
pingYesYesYes
profileAs a PaaS service, this will be managed by Azure.
serverStatusYesYesYes
shardConnPoolStatsDeprecated in MongoDB 5.0
topNoNoNo
validateYesYesYes
whatsmyuriYesYesYes
System Events Auditing CommandslogApplicationMessageNoNoNo

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" & "dbStats" works with document size less than 2KB only.

CategoryCommandFeature
v5.0v6.0v7.0
Comparison Query Operators$eqYesYesYes
$gtYesYesYes
$gteYesYesYes
$inYesYesYes
$ltYesYesYes
$lteYesYesYes
$neYesYesYes
$ninYesYesYes
Logical Query Operators$andYesYesYes
$notYesYesYes
$norYesYesYes
$orYesYesYes
Element Query Operators$existsYesYesYes
$typeYesYesYes
Evaluation Query Operators$exprYesYesYes
$jsonSchemaNoNoNo
$modYesYesYes
$regexYesYesYes
$textYesYesYes
$whereNoNoNo
Geospatial Operators$geoIntersectsYesIn Preview*
$geoWithin
$box
$center
$centerSphere
$geometry
$maxDistance
$minDistance
$polygon
$near
$nearSphere
Array Query Operators$allYesYesYes
$elemMatchYesYesYes
$sizeYesYesYes
Bitwise Query Operators$bitsAllClearYesYesYes
$bitsAllSetYesYesYes
$bitsAnyClearYesYesYes
$bitsAnySetYesYesYes
Projection Operators$YesYesYes
$elemMatchYesYesYes
$metaYesYesYes
$sliceYesYesYes
Miscellaneous Query Operators$commentNoNoNo
$randYesYesYes
$naturalNoNoNo
Field Update Operators$currentDateYesYesYes
$incYesYesYes
$minYesYesYes
$maxYesYesYes
$mulYesYesYes
$renameYesYesYes
$setYesYesYes
$setOnInsertYesYesYes
$unsetYesYesYes
Array Update Operators$YesYesYes
$[]YesYesYes
$[identifier]YesYesYes
$addToSetYesYesYes
$popYesYesYes
$pullYesYesYes
$pushYesYesYes
$pullAllYesYesYes
$eachYesYesYes
$positionYesYesYes
$sliceYesYesYes
$sortYesYesYes
Bitwise Update Operators$bitYesYesYes
Arithmetic Expression Operators$absYesYesYes
$addYesYesYes
$ceilYesYesYes
$divideYesYesYes
$expYesYesYes
$floorYesYesYes
$lnYesYesYes
$logYesYesYes
$log10YesYesYes
$modYesYesYes
$multiplyYesYesYes
$powYesYesYes
$roundYesYesYes
$sqrtYesYesYes
$subtractYesYesYes
$truncYesYesYes
Array Expression Operators$arrayElemAtYesYesYes
$arrayToObjectYesYesYes
$concatArraysYesYesYes
$filterYesYesYes
$firstNYesYesYes
$inYesYesYes
$indexOfArrayYesYesYes
$isArrayYesYesYes
$lastNYesYesYes
$mapYesYesYes
$maxNNoNo
$minNNoNo
$objectToArrayYesYesYes
$rangeYesYesYes
$reduceYesYesYes
$reverseArrayYesYesYes
$sizeYesYesYes
$sliceYesYesYes
$sortArrayNoNo
$zipNoNoNo
Bitwise Operators$bitAndYesYesYes
$bitNotYesYesYes
$bitOrYesYesYes
$bitXorYesYesYes
Boolean Expression Operators$andYesYesYes
$notYesYesYes
$orYesYesYes
Comparison Expression Operators$cmpYesYesYes
$eqYesYesYes
$gtYesYesYes
$gteYesYesYes
$ltYesYesYes
$lteYesYesYes
$neYesYesYes
Custom Aggregation Expression OperatorsNot supported yet.
Data Size Operators$bsonSizeYesYesYes
$binarySizeYesYesYes
Date Expression Operators$dateAddYesYesYes
$dateDiffYesYesYes
$dateFromPartsYesYesYes
$dateFromStringYesYesYes
$dateSubtractYesYesYes
$dateToPartsYesYesYes
$dateToStringYesYesYes
$dateTruncYesYesYes
$dayOfMonthYesYesYes
$dayOfWeekYesYesYes
$dayOfYearYesYesYes
$hourYesYesYes
$isoDayOfWeekYesYesYes
$isoWeekYesYesYes
$isoWeekYearYesYesYes
$millisecondYesYesYes
$minuteYesYesYes
$monthYesYesYes
$secondYesYesYes
$toDateYesYesYes
$weekYesYesYes
$yearYesYesYes
Literal Expression Operator$literalYesYesYes
Miscellaneous Operators$getFieldNoNoNo
$randYesYesYes
$sampleRateNoNoNo
Object Expression Operators$mergeObjectsYesYesYes
$objectToArrayYesYesYes
$setFieldYesYesYes
Set Expression Operators$allElementsTrueYesYesYes
$anyElementTrueYesYesYes
$setDifferenceYesYesYes
$setEqualsYesYesYes
$setIntersectionYesYesYes
$setIsSubsetYesYesYes
$setUnionYesYesYes
String Expression Operators$concatYesYesYes
$dateFromStringNoNoNo
$dateToStringYesYesYes
$indexOfBytesYesYesYes
$indexOfCPYesYesYes
$ltrimYesYesYes
$regexFindYesYesYes
$regexFindAllYesYesYes
$regexMatchYesYesYes
$replaceOneYesYesYes
$replaceAllYesYesYes
$rtrimYesYesYes
$splitYesYesYes
$strLenBytesYesYesYes
$strLenCPYesYesYes
$strcasecmpYesYesYes
$substrYesYesYes
$substrBytesYesYesYes
$substrCPYesYesYes
$toLowerYesYesYes
$toStringYesYesYes
$trimYesYesYes
$toUpperYesYesYes
Text Expression Operator$metaYesYesYes
Timestamp Expression Operators$tsIncrementYesYesYes
$tsSecondYesYesYes
Trigonometry Expression OperatorsNot supported yet.
Type Expression Operators$convertYesYesYes
$isNumberYesYesYes
$toBoolYesYesYes
$toDateYesYesYes
$toDecimalYesYesYes
$toDoubleYesYesYes
$toIntYesYesYes
$toLongYesYesYes
$toObjectIdYesYesYes
$toStringYesYesYes
$typeYesYesYes
Accumulators ($group, $bucket, $bucketAuto, $setWindowFields)$accumulatorNoNoNo
$addToSetYesYesYes
$avgYesYesYes
$bottomNoNo
$bottomNNoNo
$countYesYesYes
$firstYesYesYes
$firstNYesYesYes
$lastYesYesYes
$lastNYesYesYes
$maxYesYesYes
$maxNNoNo
$medianNoNoNo
$mergeObjectsYesYesYes
$minYesYesYes
$percentileNoNoNo
$pushYesYesYes
$stdDevPopNoNoNo
$stdDevSampNoNoNo
$sumYesYesYes
$topNoNo
$topNNoNo
Accumulators (in Other Stages)$avgNoNoNo
$firstYesYesYes
$lastYesYesYes
$maxNoNoNo
$medianNoNoNo
$minNoNoNo
$percentileNoNoNo
$stdDevPopNoNoNo
$stdDevSampNoNoNo
$sumNoNoNo
Variable Expression OperatorsNot supported yet.
Window OperatorsNot supported yet.
Conditional Expression Operators$condYesYesYes
$ifNullYesYesYes
$switchYesYesYes
Aggregation Pipeline Stages$addFieldsYesYesYes
$bucketNoNoNo
$bucketAutoNoNoNo
$changeStreamNoNoNo
$changeStreamSplitLargeEventNoNoNo
$collStatsYesYesYes
$countYesYesYes
$densifyNoNo
$documentsNoNo
$facetYesYesYes
$fillNoNo
$geoNearYesYesYes
$graphLookupYesYesYes
$groupYesYesYes
$indexStatsYesYesYes
$limitYesYesYes
$listSampledQueriesNoNoNo
$listSearchIndexesNoNoNo
$listSessionsNoNoNo
$lookupYesYesYes
$matchYesYesYes
$mergeNoNoNo
$outNoNoNo
$planCacheStatsNoNoNo
$projectYesYesYes
$redactNoNoNo
$replaceRootYesYesYes
$replaceWithYesYesYes
$sampleYesYesYes
$searchYesYesYes
$searchMetaYesYesYes
$setYesYesYes
$setWindowFieldsNoNoNo
$skipYesYesYes
$sortYesYesYes
$sortByCountYesYesYes
$unionWithNoNoNo
$unsetYesYesYes
$unwindYesYesYes
$shardedDataDistributionNoNoNo
$changeStreamNoNoNo
$currentOpYesYesYes
$listLocalSessionsNoNoNo
$documentsNoNoNo
Variables in Aggregation ExpressionsNOWNoNoNo
ROOTYesYesYes
REMOVEYesYesYes
CURRENTYesYesYes
CLUSTER_TIMENoNoNo
DESCENDNoNoNo
PRUNENoNoNo
KEEPNoNoNo
SEARCH_METANoNoNo
USER_ROLESNoNoNo

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

CommandSupported
Single Field IndexYes
Compound IndexYes
Multikey IndexYes
Text IndexYes
Wildcard IndexYes
Geospatial IndexYesIn Preview*
Hashed IndexYes
Vector Index (only available in Cosmos DB)YesYes, with vector search

Index properties

CommandSupported
TTLYes
UniqueYes
PartialYes
Case InsensitiveNo
SparseYes
BackgroundYes

Next steps