[documentdb] Add DocumentDB (Mongo vCore) CLI extension#10059
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, |
|
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>
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>
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
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. |
| 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) | ||
|
|
| @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 | ||
| """ |
| 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) |
|
[Release] Update index.json for extension [ documentdb-1.0.0b1 ] : https://dev.azure.com/msazure/One/_build/results?buildId=171153343&view=results |
olivertowers
left a comment
There was a problem hiding this comment.
Some things we need to fix up
Key gap - we need to add testing for replica/restore/CMK (user managed identity) to validate the command set fully.
| args_schema = super()._build_arguments_schema(*args, **kwargs) | ||
| _keep_only_args(args_schema, {"cluster_name", "resource_group", "admin_password"}) | ||
| password = args_schema.admin_password | ||
| password._options = ["--password", "-p"] |
There was a problem hiding this comment.
Argument name consistency between this command (--password, -p) and what the cluster create/update accepts( --admin-password), let's add the same set of aliases on both sides so that it is consistent.
| from azure.cli.testsdk.scenario_tests.decorators import AllowLargeResponse | ||
|
|
||
|
|
||
| class DocumentdbScenario(ScenarioTest): |
There was a problem hiding this comment.
I don't see tests for restore, replica, CMK, users etc.
| 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) |
There was a problem hiding this comment.
Should we add a wait commands for these sub-command groups?
don't know if the standard pattern is that for every sub-command that supports a LRO command, there should be a corresponding 'wait' command eg.
az documendb mongocluster replica create .... -nowait
....<do some other stuff>
az documentdb mongocluster replica waitThere was a problem hiding this comment.
Perhaps this is already generated somewhere I just couldn't see it - I did think the liniter/style checks would have failed on this.
There was a problem hiding this comment.
Wait commands are generated for most of the sub groups: mongocluster , mongocluster user , mongocluster firewall-rule and mongocluster identity all expose a wait . The one group without its own wait is replica , and that is expected. A replica is itself a Microsoft.DocumentDB/mongoClusters resource, the same resource type as the primary, so it is already covered by the top level az documentdb mongocluster wait -n -g . I verified that mongocluster wait --exists returns 0 against a cluster, and that both replica create and replica promote expose --no-wait . A dedicated replica wait would just duplicate the mongocluster one. On the linter: the CLI linter and style checks do not require a wait command for every LRO command, so no failure is expected here.
|
|
||
|
|
||
| @register_command( | ||
| "workload-orchestration context site-reference create", | ||
| "documentdb mongocluster firewall-rule create", |
There was a problem hiding this comment.
Did we reach agreement that we would use firewall-rule instead of the AZ cli standard network rule?
There was a problem hiding this comment.
Abinav Rameesh review the tree command and there was not issue from his side, I will share the doc why is better to use firewall-rule instead of network rule
|
documentdb |
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.