Share via

Azure DocumentDB / Cosmos DB for MongoDB vCore — enable Preview $jsonSchema collection validators on cluster

Ghaith Almasri 40 Reputation points
2026-05-14T20:34:01.4133333+00:00

Looking to enable the Preview $jsonSchema collection validator feature introduced in the Oct 10 2025 service release notes (engine build 1017: "Add schema validation support for $jsonSchema during rule creation or modification") on our vCore cluster.

Cluster details. Resource: linramongodb-eu. Resource group: rg-fizzychat-prod. Subscription: b28ab9df-7c51-4dd2-b59d-1a3d43ae21d7 (Microsoft Azure Sponsorship). Region: Germany North. Tier: M20 burstable, 32 GB Premium SSD. Server version: 8.0 (confirmed via buildInfo). Resource type: Microsoft.DocumentDB/mongoClusters.

What we see today: every collection-validator path is rejected with errmsg "validator not supported yet". Tested all of: db.createCollection(name, { validator: { $jsonSchema: ... } }) rejected; db.command({ collMod, validator }) rejected; validationAction "warn" rejected; validator {} with validationLevel "off" rejected (even disabling requires the feature); listCollections returning validator options rejected.

Query-side $jsonSchema used inside $match works fine. It's specifically the collection-level write enforcement that's gated.

Could the Preview flag be enabled on this cluster? Happy to accept the Preview risks. Couldn't find a self-serve toggle: checked the stable and 2026-02-01-preview ARM API surface and az feature list --namespace Microsoft.DocumentDB (50+ flags, none for validators).

Use case: pair Mongo-engine validation with our existing app-side Zod validators so any write path (app, migration script, ad-hoc Mongo shell) is gated by the same schema. Without it, schema enforcement is app-only and anything that bypasses our wrapper gets through.

Thanks!

Azure Cosmos DB
Azure Cosmos DB

An Azure NoSQL database service for app development.


Answer accepted by question author

kagiyama yutaka 3,430 Reputation points
2026-05-19T04:27:19.7833333+00:00

I think u can’t enable this preview on vCore at all. It’s a service side rollout only, so for now just keep ur app schema guarding writes and do a tiny scratch DB insert to catch drift early.

Was this answer helpful?

2 people found this answer helpful.
0 comments No comments

1 additional answer

Sort by: Most helpful
  1. AI answer

    2026-05-14T20:34:15.91+00:00

    The $jsonSchema collection validator feature in Azure DocumentDB (MongoDB compatibility) is in Preview and must be explicitly enabled as a preview feature on the subscription/cluster before collection-level validators can be used. Until the preview is registered, commands that configure collection validators will continue to fail with errors such as "validator not supported yet", even though $jsonSchema works inside queries.

    The October 10, 2025 engine release (build 1017) explicitly marks schema validation support for $jsonSchema as [Preview] and notes that preview items require enablement:

    • Schema validation support for $jsonSchema during rule creation or modification is a preview engine enhancement.
    • Items tagged as [Preview] require a support request to enable them on a cluster.

    To enable this preview feature for the specified Azure DocumentDB cluster:

    1. Register the preview feature for Microsoft.DocumentDB in the subscription:
      1. In the Azure portal, open the Preview features blade for the subscription.
      2. Under Type, select Microsoft.DocumentDB.
      3. In the list of available preview features, locate the entry corresponding to $jsonSchema schema validation / collection validators (the exact name is defined in the preview-features list for Microsoft.DocumentDB).
      4. Select it and choose Register.
    2. If the registration remains in Pending for an abnormal amount of time, create an Azure support request and reference that the cluster is on engine build 1017+ and needs the $jsonSchema schema validation preview enabled. Azure support can confirm eligibility and complete enablement for the specific mongoClusters resource.
    3. After the preview is active on the cluster, retry the collection-level operations, for example:
      • db.createCollection(<name>, { validator: { $jsonSchema: { ... } } })
      • db.runCommand({ collMod: <name>, validator: { $jsonSchema: { ... } } })

    Supported $jsonSchema keywords in Azure DocumentDB include bsonType, properties, required, minLength, maxLength, minimum, maximum, items, minItems, maxItems, uniqueItems, and others. Keywords such as additionalProperties, enum, allOf, anyOf, oneOf, and not are not supported and must be handled via application logic or alternative query operators like $in.

    If the preview feature does not appear in the subscription’s Preview features list, or if registration plus propagation still leaves validators disabled, open an Azure support ticket for the subscription and request that the $jsonSchema schema validation preview be enabled for the specific Microsoft.DocumentDB/mongoClusters resource.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.