Skip to content

Sachim/documentdb gap analysis fixes - #10188

Open
sachim wants to merge 20 commits into
Azure:mainfrom
sachim:sachim/documentdb-gap-analysis-fixes
Open

Sachim/documentdb gap analysis fixes#10188
sachim wants to merge 20 commits into
Azure:mainfrom
sachim:sachim/documentdb-gap-analysis-fixes

Conversation

@sachim

@sachim sachim commented Aug 6, 2026

Copy link
Copy Markdown

🤖 PR Validation — ❌ Action needed

Breaking Changes
❌ 1
❌Azure CLI Extensions Breaking Change Test
❌documentdb
rule cmd_name rule_message suggest_message
1007 - ParaRemove documentdb mongocluster replica create cmd documentdb mongocluster replica create removed parameter source_location please add back parameter source_location for cmd documentdb mongocluster replica create
1006 - ParaAdd documentdb mongocluster replica list cmd documentdb mongocluster replica list added parameter source_cluster please remove parameter source_cluster for cmd documentdb mongocluster replica list
1007 - ParaRemove documentdb mongocluster replica list cmd documentdb mongocluster replica list removed parameter cluster_name please add back parameter cluster_name for cmd documentdb mongocluster replica list
1006 - ParaAdd documentdb mongocluster replica promote cmd documentdb mongocluster replica promote added parameter source_cluster please remove parameter source_cluster for cmd documentdb mongocluster replica promote
1012 - SubgroupRemove documentdb mongocluster user sub group documentdb mongocluster user removed please confirm sub group documentdb mongocluster user removed
⚠️ 1010 - ParaPropUpdate documentdb mongocluster create cmd documentdb mongocluster create update parameter admin_password: updated property options from ['--admin-password', '-p'] to ['--admin-password', '--password', '-p']
⚠️ 1001 - CmdAdd documentdb mongocluster identity list cmd documentdb mongocluster identity list added
⚠️ 1006 - ParaAdd documentdb mongocluster identity remove cmd documentdb mongocluster identity remove added parameter yes
⚠️ 1011 - SubgroupAdd documentdb mongocluster microsoft-entra-user sub group documentdb mongocluster microsoft-entra-user added
⚠️ 1006 - ParaAdd documentdb mongocluster replica promote cmd documentdb mongocluster replica promote added parameter yes
⚠️ 1010 - ParaPropUpdate documentdb mongocluster reset-password cmd documentdb mongocluster reset-password update parameter admin_password: updated property options from ['--password', '-p'] to ['--admin-password', '--password', '-p']
⚠️ 1010 - ParaPropUpdate documentdb mongocluster restore cmd documentdb mongocluster restore update parameter admin_password: updated property options from ['--admin-password', '-p'] to ['--admin-password', '--password', '-p']
⚠️ 1010 - ParaPropUpdate documentdb mongocluster update cmd documentdb mongocluster update update parameter admin_password: updated property options from ['--admin-password', '-p'] to ['--admin-password', '--password', '-p']

Summary

This PR delivers the Azure DocumentDB CLI extension (az documentdb mongocluster, the Microsoft.DocumentDB/mongoClusters resource, API 2026-06-01) together with a round of gap-analysis fixes that make the command surface consistent, safer, and better documented.

Command surface

  • az documentdb mongocluster — create/update/show/list/delete clusters, list-connection-strings, reset-password
  • firewall-rule — manage IP firewall rules (public access)
  • microsoft-entra-user — assign/show/list/remove Microsoft Entra ID database users
  • identity — assign/show/list/remove user-assigned managed identity
  • replica — list/create/promote cross-region read replicas
  • restore — point-in-time restore to a new cluster

Gap-analysis fixes

  • --source-cluster rename — replaced --parent-cluster-name / --parent-location on replica list, replica create, replica promote, and restore with a single --source-cluster argument that accepts a cluster name or full ARM ID. The source location is now resolved automatically from the source cluster instead of being passed by hand.
  • microsoft-entra-user rename — the entra-user command group is now microsoft-entra-user; removed the unsupported entra-user update command (the service does not support updating an existing Entra user).
  • identity list — added a list command for the cluster's user-assigned managed identities.
  • Promote guardreplica promote now requires --source-cluster and validates that the named replica actually belongs to that source, raising a clear error on mismatch to prevent promoting the wrong replica. Added a destructive-operation confirmation prompt.
  • Confirmation prompts — added --yes/confirmation prompts to destructive operations (replica promote, identity remove).
  • --ids support — enabled resource-ID addressing via id_part on the relevant commands.
  • Password flag consistency — administrator password is --password/-p/--admin-password across create, update, reset-password, and restore.
  • DocsREADME.md updated to reflect all of the above; stale entra-user / parent-cluster-name references removed from the README and test recordings.

Tests

End-to-end scenario tests (recorded live and verified in playback) cover cluster CRUD + connection strings + reset-password, firewall rules, Microsoft Entra users, managed identity, CMK encryption, cross-region replica create, replica promote, and point-in-time restore. Each scenario is an independent test with its own recording.

Note: this branch is based on the feature-documentDB-v2 work, so the diff against main also includes the changes from PR #10113.


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

Related command

az documentdb mongocluster

General Guidelines

  • Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • Have you run python scripts/ci/test_index.py -q locally? (pip install azdev required)
  • My extension version conforms to the Extension version schema

For new extensions:

About Extension Publish

There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update src/index.json automatically.
You only need to update the version information in file setup.py and historical information in file HISTORY.rst in your PR but do not modify src/index.json.

amatarritamicrosoft and others added 12 commits July 13, 2026 16:03
Addresses PR review feedback.

Adds end to end scenario coverage for mongocluster user, cross region
replica (GeoAsyncReplica) and point in time restore, recorded live and
verified in playback. A _wait_for_restore_point helper waits (only while
recording) for the first backup, and _cmd_retry reissues a mutating
command while the service still reports an operation in progress.

Fixes _keep_only_args so deregistered arguments are also marked optional.
Previously a hidden but still required argument (the base create password
on a replica) failed schema validation with a missing required field
error, so replica create could not run.

Renames the administrator password flag to --password/-p on create and
update for consistency with reset-password and restore.

Fixes a typo in the user show help text.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8bf5e49a-3c3e-4dfe-851d-1f2790a2852b
Each mongocluster scenario (crud, firewall, user, identity, replica,
restore, cmk) is now an independent test with its own recording, so a
failure in one does not mask the others and a single scenario can be
re-recorded on its own. Adds coverage for managed identity
(assign/show/remove) and customer-managed key (CMK) encryption at rest,
and replaces the monolithic lifecycle recording.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8bf5e49a-3c3e-4dfe-851d-1f2790a2852b
The generated replica promote command sent {mode, promoteOption} at the
request root, which the service rejects with a schema error, and passed a
null final-result callback to the long-running-operation poller, which
raised a TypeError once the operation completed. The custom.py wrapper now
nests the body under "properties" and supplies a no-op callback, mirroring
how the generated delete handles its empty response. Adds an end-to-end
promote scenario test (source + cross-region replica, forced switchover,
asserts the replica settles into the primary role) plus a helper that waits
out the brief post-operation Updating state.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8bf5e49a-3c3e-4dfe-851d-1f2790a2852b
Adds a negative test covering client-side validation (invalid --storage-type
and --high-availability enum values, invalid --mode, and a missing required
--promote-option, all asserted via SystemExit) and service rejections
(show/firewall-rule show/user show/replica list against a cluster that does
not exist, asserted with expect_failure). This matches the negative-case
convention used by the official cosmosdb CLI tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8bf5e49a-3c3e-4dfe-851d-1f2790a2852b
…identity check

Resolve mongocluster scenario test review feedback:
* Expose all three password aliases (--admin-password, --password, -p) on
  create, update, reset-password, and restore. Examples show --admin-password.
* Exercise the native wait command explicitly: firewall uses create --no-wait
  then firewall-rule wait --created. Replace the two hand authored pollers with
  mongocluster wait --custom in the restore and promote tests.
* Use 0.0.0.0 firewall ranges instead of a hardcoded test IP.
* Validate the user assigned identity in the CMK test through identity show
  (type, key presence, and principalId).
* Fix user command examples to a pattern valid username (alice-entra).

Recorded the affected cassettes again (firewall, restore, promote, cmk). All
nine scenario tests pass in playback. Style and linter pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8bf5e49a-3c3e-4dfe-851d-1f2790a2852b
…id identifier

Address Oliver Towers' PR review on the mongocluster user commands: the users
API only supports Microsoft Entra ID principals today, so the generic `user`
naming misleads customers about what is provisioned and what identifier to pass.

- Rename command group `mongocluster user` -> `mongocluster entra-user`.
- Rename the identifier arg `--user-name` -> `--object-id` (keeps `-n`/`--name`
  aliases); help now states it is the Entra object (client) ID GUID, not a
  friendly name or UPN.
- Make all command/group help Entra-specific; fix "defintion" typo in show.
- Update examples to use a GUID object id.
- Fix roles singular option in the aaz model (was generating ----role).
- Re-record the entra-user and negative scenario tests live; both pass playback.

The flat --type wrapper (custom.py) and its command-table registration are
rewired to the entra-user name so the flattening survives the rename.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 40a4fbc4-fd62-4bcc-9b7d-6e70f80e114d
Address Oliver Towers' PR review: an entra-user binding grants an already-existing
Microsoft Entra principal data-plane access to the cluster (a roles assignment),
rather than creating a new user. Rename the commands `entra-user create` -> `assign`
and `entra-user delete` -> `remove` (verbs only; group and update/show/list stay),
matching the sibling `mongocluster identity assign/remove`.

- Regenerated aaz code: _assign.py/_remove.py with classes Assign/Remove.
- custom.py/commands.py: the flat --type wrapper is rewired to `entra-user assign`.
- Updated README and the scenario test; re-recorded the user cassette live.

Pairs with the aaz model change in Azure/aaz.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 40a4fbc4-fd62-4bcc-9b7d-6e70f80e114d
Version bump for the entra-user rename work (user -> entra-user, --object-id,
create/delete -> assign/remove, password aliases). Adds the 1.0.0b2 changelog entry.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 40a4fbc4-fd62-4bcc-9b7d-6e70f80e114d
Two release-readiness fixes for the extension:

- Mark all command groups and commands as Preview (stage=Preview in the aaz
  model, regenerated here) so the CLI reference docs show Preview instead of GA.
- Rebrand the product name to "Azure DocumentDB": update README, HISTORY, the
  service_name.json mapping, and the root/mongocluster group help.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 40a4fbc4-fd62-4bcc-9b7d-6e70f80e114d
Regenerate replica list from the aaz model and update the hand written
replica create and restore wrappers so the parent cluster and its region
use parent-cluster-name and parent-location instead of source-cluster and
source-location, per review feedback. Also updates the scenario tests and
the README. The ARM property names sourceResourceId and sourceLocation are
unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 40a4fbc4-fd62-4bcc-9b7d-6e70f80e114d
- Rename replica/restore source arg to --source-cluster (name-or-ARM-ID);
  derive replica source location from the source cluster; drop --parent-location
- Rename 'replica list' arg to --source-cluster
- Add 'replica promote' --source-cluster guard (validate vs replica sourceResourceId)
- Add confirmations to 'identity remove' and 'replica promote'
- Add 'identity list' command
- Rename 'entra-user' group to 'microsoft-entra-user'
- Remove 'entra-user update' (unsupported by service)
- Update scenario tests for renamed args/commands
Copilot AI lite review requested due to automatic review settings August 6, 2026 17:53
@azure-client-tools-bot-prd

Copy link
Copy Markdown

Hi sachim,
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.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@sachim
sachim marked this pull request as draft August 6, 2026 17:54
@azure-client-tools-agent

Copy link
Copy Markdown

Automated sensitive-information remediation ran on this pull request.

  • Detected categories: credential
  • Replaced with typed [REDACTED:category] placeholders in: no writable PR fields
  • Could not edit: file changes on a fork branch
  • Comment/review owners notified because Agent Assist cannot edit another user's text: none

If a credential was exposed, rotate or revoke it immediately. Detected values are never copied into this comment.

✅ Keep the redaction · ❌ Dispute the redaction

GitHub only supports a fixed reaction set, so 👍 represents ✅ and 👎 represents ❌. The bot-created reactions are only poll choices.


Posted by agent-assist (autonomous bug-fix pipeline).

@azure-client-tools-agent azure-client-tools-agent Bot added the azure-client-tools-agent Pull request commented on or reviewed by Azure Client Tools Agent label Aug 6, 2026
@sachim

sachim commented Aug 6, 2026

Copy link
Copy Markdown
Author

sachim please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree company="Microsoft"

@microsoft-github-policy-service microsoft-github-policy-service Bot added the customer-reported Issues that are reported by GitHub users external to the Azure organization. label Aug 6, 2026
@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

Thank you for your contribution sachim! We will review the pull request and get back to you soon.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

…luster guard; re-record crud/identity/promote
@sachim
sachim requested a balanced review from Copilot August 6, 2026 20:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

… 4.5); reset-password includes current admin login; re-record crud
@sachim
sachim marked this pull request as ready for review August 6, 2026 22:12

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.

lgtm - just some test gaps we should resolve.

I largely used the test scenarios as my way of reviewing how things worked, so use the test scenarios as the full functional spec definition for the commands for coverage.

Goal should be coverage of each command and each parameter specific to command that we are adding.

Comment thread src/documentdb/azext_documentdb/tests/latest/test_documentdb.py Outdated
Comment thread src/documentdb/azext_documentdb/tests/latest/test_documentdb.py
@sachim
sachim marked this pull request as ready for review August 6, 2026 23:16
@sachim
sachim marked this pull request as draft August 6, 2026 23:16
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@sachim sachim changed the title [Do Not Merge] Sachim/documentdb gap analysis fixes Sachim/documentdb gap analysis fixes Aug 10, 2026
@sachim
sachim requested a balanced review from Copilot August 10, 2026 14:57
@sachim
sachim marked this pull request as ready for review August 10, 2026 14:58
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 40 out of 50 changed files in this pull request and generated 1 comment.

Suppressed comments (6)

src/documentdb/HISTORY.rst:27

  • This rewrites the beta1 history to claim that entra-user was initially released, but the beta1 command was mongocluster user (as also implied by the migration note above). Preserve the historical command name so users can understand the upgrade path.
* Add ``az documentdb mongocluster entra-user`` commands to manage Microsoft Entra ID
  database users.

src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/replica/_list.py:53

  • --source-cluster is documented for this PR as accepting a name or full ARM ID, but this schema rejects IDs with its name-only regex and the request always uses the current resource group/subscription. As a result, replica list --source-cluster <ARM-ID> cannot work, unlike create/restore/promote. Resolve and decompose the source ID before building the URL, and cover the ARM-ID form in the scenario test.
    src/documentdb/azext_documentdb/custom.py:149
  • This prerequisite is contradicted by the added replica scenario: _create_cluster() does not enable GeoReplicas, yet the recorded replica creation succeeds, and the properties scenario explicitly says the flag is unrelated to replica creation. Keeping this sentence will incorrectly tell users to modify the source cluster first.
    src/documentdb/README.md:85
  • The added live recording creates a replica from a source without previewFeatures, and the test states that GeoReplicas is unrelated to replica creation. This prerequisite is therefore stale and would mislead users.
# Create a cross-region GeoReplica (the source must have the GeoReplicas preview feature enabled).

src/documentdb/HISTORY.rst:14

  • The release note uses the intermediate entra-user name twice, but the shipped command in this release is microsoft-entra-user and beta1 exposed user. Release notes should describe the actual migration so existing users can update their scripts correctly.

This issue also appears on line 26 of the same file.

* Rename ``az documentdb mongocluster user`` to ``entra-user``; the group only supports
  Microsoft Entra ID principals, so the name makes that explicit.
* The user identifier is now ``--object-id`` (the Entra object/client ID GUID), keeping the
  ``-n``/``--name`` aliases.
* Rename ``entra-user create``/``delete`` to ``assign``/``remove``: the Entra principal already

src/documentdb/azext_documentdb/tests/latest/recordings/test_documentdb_mongocluster_negative.yaml:158

  • This recording still identifies the old --cluster-name parameter even though the test now invokes replica list --source-cluster. Re-record or update the cassette so it actually reflects the renamed command surface described by the PR.

Sachin Maske added 2 commits August 10, 2026 12:35
…uster update via GET+PATCH

The sparse-PATCH conversion (844515b) dropped AZ_SUPPORT_GENERIC_UPDATE and the instance-update pipeline, silently removing 'update --set/--add/--remove'. Restore the GET -> InstanceUpdateByJson -> InstanceUpdateByGeneric pipeline but send the merged instance via HTTP PATCH (not PUT), so untouched properties are preserved (read-only fields are skipped by serialization). Adds a --set generic-update assertion to the properties scenario; crud and properties re-recorded live.
… identity list, and confirmations in HISTORY
@sachim
sachim requested a balanced review from Copilot August 10, 2026 17:59
@sachim

sachim commented Aug 10, 2026

Copy link
Copy Markdown
Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Commenter does not have sufficient privileges for PR 10188 in repo Azure/azure-cli-extensions

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 40 out of 50 changed files in this pull request and generated no new comments.

Suppressed comments (4)

src/documentdb/HISTORY.rst:12

  • This second release-note entry also uses the nonexistent entra-user surface and obscures that both the group and operations changed. Name the old and new commands explicitly.
* Rename ``entra-user create``/``delete`` to ``assign``/``remove``: the Entra principal already

src/documentdb/HISTORY.rst:36

  • The 1.0.0b1 release exposed az documentdb mongocluster user (as shown by the removed generated commands), not entra-user. Keep the historical entry accurate rather than recording a command that never existed in that release.
* Add ``az documentdb mongocluster entra-user`` commands to manage Microsoft Entra ID

src/documentdb/azext_documentdb/aaz/latest/documentdb/mongocluster/replica/_list.py:53

  • replica list still accepts only a same-resource-group cluster name: this formatter rejects ARM IDs, and the value is serialized directly into the {mongoClusterName} path while the request keeps the current resource group/subscription. This contradicts the PR contract that --source-cluster accepts a name or full ARM ID, so listing a source in another resource group or subscription fails before/requesting the wrong path. Parse full IDs into subscription, resource group, and cluster name (as the other source-cluster wrappers do), and cover that form in the scenario test.
    src/documentdb/HISTORY.rst:9
  • The released command group is microsoft-entra-user, not entra-user, so this new release note directs users to a nonexistent group. Use the exact public command name.

This issue also appears in the following locations of the same file:

  • line 12
  • line 36
* Rename ``az documentdb mongocluster user`` to ``entra-user``; the group only supports

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.

lgtm

@yonzhan

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

@azure-client-tools-agent

Copy link
Copy Markdown

Automated sensitive-information remediation ran on this pull request.

  • Detected categories: unknown
  • Replaced with typed [REDACTED:category] placeholders in: no writable PR fields
  • Could not edit: file changes on a fork branch
  • Comment/review owners notified because Agent Assist cannot edit another user's text: none

If a credential was exposed, rotate or revoke it immediately. Detected values are never copied into this comment.

✅ Keep the redaction · ❌ Dispute the redaction

GitHub only supports a fixed reaction set, so 👍 represents ✅ and 👎 represents ❌. The bot-created reactions are only poll choices.


Posted by agent-assist (autonomous bug-fix pipeline).

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

Labels

azure-client-tools-agent Pull request commented on or reviewed by Azure Client Tools Agent customer-reported Issues that are reported by GitHub users external to the Azure organization.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants