Cosmos DB's other APIs and Azure DocumentDB — MongoDB (RU), DocumentDB (vCore) with Entra, Table, Cassandra and Gremlin

Which MongoDB-compatible or wire-protocol database to pick and how each authenticates — Azure DocumentDB (formerly Cosmos DB for MongoDB vCore) with Microsoft Entra users registered as mongoClusters/users and the MONGODB-OIDC driver flow from TypeScript, Cosmos DB for MongoDB (RU) with its error codes and 4-minute idle drop, Cosmos DB for Table's native data-plane roles, and where Microsoft now points Cassandra and Gremlin users.

markdownreferencev1TC9A-YQ8Nstage: designtrust: officialservice: cosmos-dbinterface: sdkinterface: cliAzure DocumentDBAzure Cosmos DB for MongoDB vCore renamedmongoClustersMicrosoft.DocumentDB/mongoClusters/usersauthConfig allowedModes NativeAuth MicrosoftEntraIDMONGODB-OIDCOIDC_CALLBACKALLOWED_HOSTS *.azure.commongocluster.cosmos.azure.comossrdbms-aad DocumentDBCosmos DB for MongoDB RUmongo.cosmos.azure.comMongo error 16500 TooManyRequestsMongo error 50 ExceededTimeLimitMongo error 13 UnauthorizedMongo error 11000 DuplicateKeyMongo error 61 ShardKeyNotFoundMongo error 2 BadValue indexmaxIdleTimeMS 120000appName=@accountName@Cosmos DB for Table RBACtables/containers/entitiesCosmos DB for Apache CassandraAzure Managed Instance for Apache CassandraCosmos DB for Apache GremlinGraph in Microsoft Fabric

Created 21 Oct 2026 · Modified 23 Oct 2026 · 1 version

Cosmos DB's other APIs and Azure DocumentDB

NeedMicrosoft points to
Migrate a MongoDB app, or use MQL featuresAzure DocumentDB (vCore clusters, formerly Cosmos DB for MongoDB vCore, built on the open-source DocumentDB project)
Global scale, 99.999% SLA, instant autoscaleCosmos DB for NoSQL (reference/cosmos-db/access-and-modeling.md)
Migrate an Apache Cassandra appAzure Managed Instance for Apache Cassandra rather than Cosmos DB for Apache Cassandra
Graph analytics, or migrate a Gremlin appGraph in Microsoft Fabric rather than Cosmos DB for Apache Gremlin

Azure DocumentDB with Microsoft Entra

  1. Allow Entra alongside native users first (keep NativeAuth until Entra sign-in works): authConfig.allowedModes: ['NativeAuth', 'MicrosoftEntraID'] on Microsoft.DocumentDB/mongoClusters (the documentdb CLI extension's mongocluster update takes --auth-allowed-modes).
  2. Register each principal as a cluster user: a Microsoft.DocumentDB/mongoClusters/users resource named <cluster>/users/<object id>, with identityProvider.type: MicrosoftEntraID, a principalType and roles such as {"db": "sales", "role": "readWrite"}, readAnyDatabase, readWriteAnyDatabase with clusterAdmin, or {"db": "admin", "role": "root"}.
  3. Connect with MONGODB-OIDC; the token audience is the same as PostgreSQL's and MySQL's, https://ossrdbms-aad.database.windows.net/.default.
import { MongoClient, type OIDCCallbackParams, type OIDCResponse } from "mongodb";
import { DefaultAzureCredential, type TokenCredential } from "@azure/identity";

const SCOPE = "https://ossrdbms-aad.database.windows.net/.default"; // same audience as PostgreSQL and MySQL

async function entraToken(_params: OIDCCallbackParams, credential: TokenCredential): Promise<OIDCResponse> {
  const t = await credential.getToken(SCOPE);
  if (!t) throw new Error("no token");
  return { accessToken: t.token, expiresInSeconds: Math.floor((t.expiresOnTimestamp - Date.now()) / 1000) };
}

const credential = new DefaultAzureCredential();

// The identity must be registered as a cluster user (mongoClusters/users) with a role such as readWrite on the database.
export const client = new MongoClient(`mongodb+srv://${process.env.DOCUMENTDB_CLUSTER}.global.mongocluster.cosmos.azure.com/`, {
  tls: true,
  retryWrites: true,
  connectTimeoutMS: 120_000,
  authMechanism: "MONGODB-OIDC",
  authMechanismProperties: {
    OIDC_CALLBACK: (params: OIDCCallbackParams) => entraToken(params, credential),
    ALLOWED_HOSTS: ["*.azure.com"],
  },
});

export async function main(): Promise<void> {
  await client.connect();
  const orders = client.db("shop").collection<{ _id: string; customerId: string; total: number }>("orders");
  await orders.updateOne({ _id: "o-1001" }, { $set: { customerId: "c-42", total: 12.5 } }, { upsert: true });
  console.log(await orders.findOne({ _id: "o-1001" }));
  await client.close();
}

Deleting a principal in Entra doesn't remove the cluster user, and issued tokens stay valid until they expire (up to about 90 minutes): delete the users/<object id> resource to revoke at once. Storage can grow but never shrink. Some server-side MongoDB extensions and storage engines aren't supported.

Cosmos DB for MongoDB (RU)

Endpoints are <account>.mongo.cosmos.azure.com (3.6 and later; 3.2 accounts used documents.azure.com), TLS 1.2. Its RBAC (users and roles, 3.6+) is managed only with the CLI or PowerShell.

CodeMeaning → fix
16500 TooManyRequestsRUs exhausted: retry, scale, or enable server-side retry
50 ExceededTimeLimitPast the 60-second limit: more RUs, smaller requests; retried writes can duplicate
13 UnauthorizedWrong key or missing permission
11000 DuplicateKeyUnique index or shard key value already exists
61 ShardKeyNotFoundThe document lacks the shard (partition) key
66 ImmutableFieldUpdating _id or the shard key
2 BadValueSorting on a field without a matching (composite) index; or a multi-document transaction past 5 seconds
67 CannotCreateIndexOver 500 single-field indexes, or 8 fields in a compound index
112 WriteConflictConflicting transactions: retry
26 NamespaceNotFoundDatabase or collection name doesn't match
Socket / endOfStream errorsIdle pooled connections are closed after about 4 minutes: set maxIdleTimeMS=120000 (Node.js: or socketTimeoutMS with keep-alive)
Old drivers can't find the accountAppend appName=@<account>@ to the connection string

Cosmos DB for Table

Has its own native data-plane roles, like NoSQL and distinct from Azure RBAC: Built-in Data Reader (…0001: readMetadata, entity read) and Built-in Data Contributor (…0002: tables/*, tables/containers/entities/*); readMetadata must always be allowed for SDK clients, and notDataActions isn't supported. Table storage in a storage account is a different service: reference/storage/tables.md.

Read this document as markdown — the same bytes an agent receives.