Skip to content

[documentdb] Add DocumentDB (Mongo vCore) CLI extension#10059

Draft
amatarritamicrosoft wants to merge 7 commits into
Azure:mainfrom
amatarritamicrosoft:feature-documentDB
Draft

[documentdb] Add DocumentDB (Mongo vCore) CLI extension#10059
amatarritamicrosoft wants to merge 7 commits into
Azure:mainfrom
amatarritamicrosoft:feature-documentDB

Conversation

@amatarritamicrosoft

Copy link
Copy Markdown
Member

Summary

Adds a new Azure CLI extension documentdb for Azure Cosmos DB for MongoDB (vCore) — management-plane commands for Microsoft.DocumentDB/mongoClusters (api-version 2026-06-01).

Generated with the AAZ codegen tool. Companion command-model PR in Azure/aaz: Azure/aaz#1040.

Command tree

  • az documentdb mongocluster create / update / show / delete / list / list-connection-strings / check-name-availability / wait
  • az documentdb mongocluster firewall-rule create / update / show / delete / list / wait
  • az documentdb mongocluster identity assign / remove / show / wait (UserAssigned only)
  • az documentdb mongocluster replica list / promote
  • az documentdb mongocluster user create / update / show / delete / list / wait

Design notes

  • Flattened scalar arguments on create/update (no JSON blobs): --admin-user/-u, --admin-password/-p, --tier, --storage-size, --storage-type, --shard-count, --high-availability, --data-api-mode, --auth-allowed-modes. Core provisioning args required on create, optional on update.
  • user create/update accept a repeatable --role (singular option) and a custom --type/-t flag mapping to the identityProvider discriminated union (custom.py).
  • Private-endpoint / private-link commands intentionally omitted (covered by az network per current guidance).
  • New documentdb entry added to src/service_name.json.

Dependency (why this is a draft)

az documentdb is currently reserved/blocked in azure-cli core. This extension cannot be exercised until the core unblock ships in a released azure-cli:

Marking ready for review once that lands.

Testing

  • Live-tested end-to-end against Azure (create/update/delete of real mongoClusters, flattened flags, --role, --type).
  • Command models pass aaz-dev command-model verify.

This checklist is used to make sure that common guidelines for a pull request are followed.

amatarritamicrosoft and others added 2 commits July 1, 2026 00:46
Add the initial �z documentdb mongocluster extension for the
Microsoft.DocumentDB/mongoClusters resource (API 2026-06-01), generated
with aaz-dev plus custom refinements:

- Flatten cluster create/update inputs into first-class flags
  (--admin-user/--admin-password, --tier, --storage-size/--storage-type,
  --shard-count, --high-availability, --data-api-mode, --auth-allowed-modes);
  the five provisioning inputs are required on create.
- Use --cluster-name for the parent on all sub-resources.
- Restrict managed identity to UserAssigned (service rejects SystemAssigned).
- user create/update: custom --type/-t flag over the identityProvider
  discriminated union, and repeatable --role db=x role=y (singular_options).
- Drop private-endpoint-connection / private-link-resource in favor of the
  generic az network commands.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@azure-client-tools-bot-prd

Copy link
Copy Markdown
Validation for Breaking Change Starting...

Thanks for your contribution!

@azure-client-tools-bot-prd

Copy link
Copy Markdown

Hi @amatarritamicrosoft,
Please write the description of changes which can be perceived by customers into HISTORY.rst.
If you want to release a new extension version, please update the version in setup.py as well.

@yonzhan

yonzhan commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

documentdb

@yonzhan yonzhan requested a review from Pan-Qi July 1, 2026 23:24
Add three hand-written custom commands over the AAZ-generated mongocluster surface:

- `mongocluster reset-password`: friendly wrapper over update that exposes only
  --password and maps it to the administrator object (other update flags hidden).
- `mongocluster replica create`: creates a cross-region GeoReplica from a source
  cluster (--source-cluster / --source-location); sets createMode + replicaParameters
  internally.
- `mongocluster restore`: point-in-time restore into a new cluster (--source-cluster
  / --restore-time + admin credentials); sets createMode + restoreParameters +
  administrator internally.

Since AAZ drops hide=True args from generated code, the create-variant wrappers inject
createMode/replicaParameters/restoreParameters via a content override (set_const +
set_prop) rather than hidden args. Irrelevant create/update flags are deregistered so
each command stays focused.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment on lines +11 to +13
class DocumentdbScenario(ScenarioTest):
# TODO: add tests here
pass

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would mind add some real test cases?

Comment thread src/documentdb/README.md Outdated
Comment on lines +4 to +5
## How to use ##
Please add commands usage here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to enrich that part.

amatarritamicrosoft and others added 4 commits July 2, 2026 10:51
Address PR feedback: expand the extension README with background, a command-group
table, and usage examples for clusters, firewall rules, users, identity, replicas,
reset-password, and point-in-time restore. Flesh out the 1.0.0b1 HISTORY entry with
the customer-visible command surface.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The reset-password, replica-create, and restore wrappers subclass the generated
Create/Update commands. AAZ caches the built arguments schema in the class attribute
``_arguments_schema`` (used by get_arguments_schema, the CLI parser entry point). Because
the wrappers inherit that attribute from their base command, when the base command
(create/update) loaded its schema first in the same process, the wrapper reused the
base's cached schema and never applied its own option rename/deregistration -- e.g.
``reset-password`` failed with "unrecognized arguments: --password".

Give each wrapper its own ``_arguments_schema = None`` (and ``_args_schema = None`` for
the internal build cache) so every wrapper builds and caches an isolated schema.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add a recorded ScenarioTest covering the full mongo cluster lifecycle:
check-name-availability, create, show, list, update (tags), reset-password,
firewall-rule create/show/list/delete, and delete. Every long-running operation
uses --no-wait immediately followed by the matching wait command so each step
observes a settled state and the scenario is free of state-condition races.

Includes the recorded cassette for offline playback.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Mark admin-user, admin-password, tier, storage-size, shard-count, and
high-availability as required on `mongocluster create`, matching the AAZ command
model. This gives a clear client-side error when a core provisioning input is
omitted instead of a server-side 400. storage-type stays optional, and update
keeps all of these optional so a single property can be changed in isolation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@necusjz

necusjz commented Jul 3, 2026

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Auto-Assign Auto assign by bot Code Gen

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants