[documentdb] Add DocumentDB (Mongo vCore) CLI extension#10059
Merged
Conversation
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>
|
Validation for Breaking Change Starting...
Thanks for your contribution! |
|
Hi @amatarritamicrosoft, |
Collaborator
|
documentdb |
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>
necusjz
reviewed
Jul 2, 2026
necusjz
reviewed
Jul 2, 2026
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>
Member
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
Member
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
Member
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new documentdb Azure CLI extension to manage Azure Cosmos DB for MongoDB (vCore) Microsoft.DocumentDB/mongoClusters resources (api-version 2026-06-01), primarily via AAZ-generated command modules with a small set of custom command wrappers.
Changes:
- Registers
az documentdbinservice_name.jsonand introduces a newsrc/documentdbextension package (setup + metadata + help/params loader). - Adds AAZ-generated command implementations for
documentdb mongoclusterand subgroups (firewall-rule, identity, replica, user, wait/list/show/etc.). - Adds custom wrappers for UX/behavior tweaks (
user --type/-tflattening,reset-password,replica create,restore) plus a scenario test + recording.
Reviewed changes
Copilot reviewed 54 out of 55 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/service_name.json | Registers az documentdb service entry for docs/service-name mapping. |
| src/documentdb/HISTORY.rst | Extension changelog for initial beta release. |
| src/documentdb/setup.py | Python packaging entrypoint for the extension. |
| src/documentdb/setup.cfg | Placeholder config file (consistent with other extensions). |
| src/documentdb/README.md | Extension overview + usage examples. |
| src/documentdb/azext_documentdb/init.py | Extension command loader wiring (AAZ + custom commands). |
| src/documentdb/azext_documentdb/_help.py | Help-file scaffold import for the extension. |
| src/documentdb/azext_documentdb/_params.py | Params hook (currently no extra arg customizations). |
| src/documentdb/azext_documentdb/azext_metadata.json | Extension metadata (preview + min CLI core version). |
| src/documentdb/azext_documentdb/commands.py | Registers custom command wrappers into the command table. |
| src/documentdb/azext_documentdb/custom.py | Custom wrappers: user --type, reset-password, replica create, restore. |
| src/documentdb/azext_documentdb/aaz/init.py | AAZ package marker for the extension. |
| src/documentdb/azext_documentdb/aaz/latest/init.py | AAZ latest package marker. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/init.py | AAZ root documentdb command-group module export. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/__cmd_group.py | Defines the az documentdb command group. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/init.py | Exports mongocluster command modules. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/__cmd_group.py | Defines the az documentdb mongocluster command group. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/_check_name_availability.py | AAZ implementation for mongocluster check-name-availability. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/_create.py | AAZ implementation for mongocluster create. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/_delete.py | AAZ implementation for mongocluster delete. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/_list.py | AAZ implementation for mongocluster list. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/_list_connection_strings.py | AAZ implementation for mongocluster list-connection-strings. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/_show.py | AAZ implementation for mongocluster show. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/_update.py | AAZ implementation for mongocluster update. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/_wait.py | AAZ implementation for mongocluster wait. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/firewall_rule/init.py | Exports firewall-rule command modules. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/firewall_rule/__cmd_group.py | Defines the mongocluster firewall-rule command group. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/firewall_rule/_create.py | AAZ implementation for firewall-rule create. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/firewall_rule/_delete.py | AAZ implementation for firewall-rule delete. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/firewall_rule/_list.py | AAZ implementation for firewall-rule list. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/firewall_rule/_show.py | AAZ implementation for firewall-rule show. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/firewall_rule/_update.py | AAZ implementation for firewall-rule update. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/firewall_rule/_wait.py | AAZ implementation for firewall-rule wait. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/identity/init.py | Exports identity command modules. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/identity/__cmd_group.py | Defines the mongocluster identity command group. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/identity/_assign.py | AAZ implementation for identity assign. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/identity/_remove.py | AAZ implementation for identity remove. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/identity/_show.py | AAZ implementation for identity show. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/identity/_wait.py | AAZ implementation for identity wait. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/replica/init.py | Exports replica command modules. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/replica/__cmd_group.py | Defines the mongocluster replica command group. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/replica/_list.py | AAZ implementation for replica list. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/replica/_promote.py | AAZ implementation for replica promote. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/user/init.py | Exports user command modules. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/user/__cmd_group.py | Defines the mongocluster user command group. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/user/_create.py | AAZ implementation for user create. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/user/_delete.py | AAZ implementation for user delete. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/user/_list.py | AAZ implementation for user list. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/user/_show.py | AAZ implementation for user show. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/user/_update.py | AAZ implementation for user update. |
| src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/user/_wait.py | AAZ implementation for user wait. |
| src/documentdb/azext_documentdb/tests/init.py | Test package marker. |
| src/documentdb/azext_documentdb/tests/latest/init.py | Latest-tests package marker. |
| src/documentdb/azext_documentdb/tests/latest/test_documentdb.py | Scenario test for core mongocluster + firewall-rule + reset-password flow. |
| src/documentdb/azext_documentdb/tests/latest/recordings/test_documentdb_mongocluster_lifecycle.yaml | Recorded live-test interactions for the scenario test. |
| "documentdb mongocluster user show", | ||
| ) | ||
| class Show(AAZCommand): | ||
| """Get the defintion of a Mongo cluster user. |
Comment on lines
+77
to
+82
| class UserCreate(_UserCreate): | ||
| @classmethod | ||
| def _build_arguments_schema(cls, *args, **kwargs): | ||
| args_schema = super()._build_arguments_schema(*args, **kwargs) | ||
| return _add_principal_type_arg(args_schema) | ||
|
|
Comment on lines
+124
to
+134
| @register_command("documentdb mongocluster replica create") | ||
| class ReplicaCreate(_MongoClusterCreate): | ||
| """Create a cross-region read replica of an existing mongo cluster. | ||
|
|
||
| The source cluster must have the "GeoReplicas" preview feature enabled. The replica | ||
| is provisioned as a new mongo cluster in the target region and inherits its | ||
| configuration (compute, storage, sharding) from the source cluster. | ||
|
|
||
| :example: Create a replica of a cluster in another region. | ||
| az documentdb mongocluster replica create -n MyReplica -g MyResourceGroup --location centralus --source-cluster MySourceCluster --source-location eastus2 | ||
| """ |
Comment on lines
+15
to
+21
| from azext_documentdb.custom import ( | ||
| UserCreate, UserUpdate, ResetPassword, ReplicaCreate, Restore) | ||
| self.command_table['documentdb mongocluster user create'] = UserCreate(loader=self) | ||
| self.command_table['documentdb mongocluster user update'] = UserUpdate(loader=self) | ||
| self.command_table['documentdb mongocluster reset-password'] = ResetPassword(loader=self) | ||
| self.command_table['documentdb mongocluster replica create'] = ReplicaCreate(loader=self) | ||
| self.command_table['documentdb mongocluster restore'] = Restore(loader=self) |
necusjz
approved these changes
Jul 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new Azure CLI extension
documentdbfor Azure Cosmos DB for MongoDB (vCore) — management-plane commands forMicrosoft.DocumentDB/mongoClusters(api-version2026-06-01).Generated with the AAZ codegen tool. Companion command-model PR in Azure/aaz: Azure/aaz#1040.
Command tree
az documentdb mongoclustercreate / update / show / delete / list / list-connection-strings / check-name-availability / waitaz documentdb mongocluster firewall-rulecreate / update / show / delete / list / waitaz documentdb mongocluster identityassign / remove / show / wait (UserAssigned only)az documentdb mongocluster replicalist / promoteaz documentdb mongocluster usercreate / update / show / delete / list / waitDesign notes
--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/updateaccept a repeatable--role(singular option) and a custom--type/-tflag mapping to theidentityProviderdiscriminated union (custom.py).az networkper current guidance).documentdbentry added tosrc/service_name.json.Dependency (why this is a draft)
az documentdbis currently reserved/blocked inazure-clicore. This extension cannot be exercised until the core unblock ships in a releasedazure-cli:Marking ready for review once that lands.
Testing
--role,--type).aaz-dev command-model verify.This checklist is used to make sure that common guidelines for a pull request are followed.