Repository navigation
[CosmosDB] az cosmosdb: Fix computed property preservation and fleetspace validation - #34270
Conversation
Port Azure/azure-cli-extensions#10509 and Azure/azure-cli-extensions#10436 to core using the existing Cosmos DB SDK. Preserve computed properties during SQL container updates, support non-pooled fleetspace creation, validate throughput bounds and account attachment inputs, and align help and examples. Add typed SDK and public-command regressions plus a stable non-pooled fleetspace recording. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
🟢 Approval recommended
Static review found the implementation and regression coverage consistent with the intended behavior, with no blocking issues; tests were not executed.
No open issues 🎉
What changed in this PR
Ports Cosmos DB fixes from the extension into core using the existing SDK, preserving computed properties during SQL container updates and improving fleetspace creation and validation.
Changes:
- Preserve computed properties when updating SQL containers.
- Support non-pooled fleetspace creation and validate throughput bounds and account attachment inputs.
- Align help and examples, with typed SDK tests, public-command regressions, and a non-pooled scenario recording.
| File | Description |
|---|---|
src/azure-cli/azure/cli/command_modules/cosmosdb/tests/latest/test_cosmosdb_sql_container_update.py |
Adds computed-property preservation regressions. |
src/azure-cli/azure/cli/command_modules/cosmosdb/tests/latest/test_cosmosdb_fleet_fleetspace_fleetspaceAccount_scenario.py |
Adds validation, command, help, and non-pooled scenario coverage. |
src/azure-cli/azure/cli/command_modules/cosmosdb/tests/latest/recordings/test_cosmosdb_fleetspace_non_pooled.yaml |
Records the non-pooled fleetspace lifecycle. |
src/azure-cli/azure/cli/command_modules/cosmosdb/custom.py |
Preserves computed properties and handles non-pooled creation and attachment-name checks. |
src/azure-cli/azure/cli/command_modules/cosmosdb/_validators.py |
Validates creation settings, throughput bounds, and account inputs. |
src/azure-cli/azure/cli/command_modules/cosmosdb/_params.py |
Wires creation-specific validation and updates argument guidance. |
src/azure-cli/azure/cli/command_modules/cosmosdb/_help.py |
Documents supported behavior and updates examples. |
Review effort: Balanced
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
az cosmosdb: Fix computed property preservation and fleetspace validation
|
pjohari-ms Reviewed head Upstream CIThe router snapshot for this head reports 3 completed checks: 3 passed, 0 failed. These are upstream results, not Agent live-test results. 🧪 Inspected regression evidence
Author-provided evidenceThe PR reports full Cosmos DB playback on this head (106 passed, 18 existing skips) and an author-run SQL live recording followed by playback. These are author-reported executions; the Agent did not rerun them. Test validation
⚖️ Risk assessment — 54/100 · HighThe High rating is driven by security-sensitive behavior, public CLI behavior.
Ask the Agent Tick a box to queue an action. Requires write access to this repository.
|
Seed two computed properties through the generated SDK and verify indexing and TTL changes preserve both names and queries through updates and independent CLI shows. Refresh the existing SQL container recording with real service payloads. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Addressed the computed-property persistence coverage finding in commit e65572d.
The PR description now contains the exact commands/results and explicitly separates local tooling limitations and prior-head CI from validation of this follow-up. No production-code changes or Agent live-test dispatch were made. |
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
🤖 PR Validation — ️✔️ All clear
Related command
az cosmosdb sql container updateaz cosmosdb fleetspace createaz cosmosdb fleetspace updateaz cosmosdb fleetspace account createDescription
Port the applicable maintenance fixes from Azure/azure-cli-extensions#10509 and Azure/azure-cli-extensions#10436 into the hand-written core Cosmos DB module:
properties.throughputPoolConfigurationis omitted,null, or{}. Continue requiring a nonblank service tier and a nonempty list of nonblank data regions on create.Compatibility: malformed inputs, inverted bounds, blank locations, and attachment aliases now fail before the write. Valid pooled request payloads and existing public flags are unchanged. This does not add partial throughput updates, pooling-disable commands, new API-kind behavior, SDK upgrades, or raw HTTP workarounds.
Source provenance: Azure/azure-cli-extensions#10509 was open when ported, using head
6a1cf6778af33139be0264e9a8b2db70be8f2fc9; Azure/azure-cli-extensions#10436 was merged, using headc88c75f1d4d9dfcde269fd2e0ba8d9cb3df05491. Extension-only SDK imports and unrelated recording refreshes were not copied.Testing Guide
Validated commit:
e65572d075098f1663676ab082b236dc2e6e9111. Runtime: Python 3.14.7, Azure CLI/core 2.91.0, declared and installedazure-mgmt-cosmosdb==10.0.0, native default API2026-03-15.Full Cosmos DB module playback follow-up
The entire latest-profile module passed locally on this same head: 106 passed, 18 existing skips, no failures, in 53.34 seconds (124 collected tests; JUnit totals additionally account for 127 passing unittest subtests). No test was newly excluded to obtain this result; all 18 skips are existing repository decorators.
For playback, remove
AZURE_TEST_RUN_LIVEinstead of assigning the string'false': the SDK configuration parses that string as false, but@live_onlyuses environment-value truthiness. The temporary, uncommitted pytest plugin below also rejects unskipped missing cassettes, forces VCR read-only mode, and blocks DNS/socket operations. A process-local thread switch interval of 0.0001 seconds prevents the test SDK's no-sleep CLI polling loop from starving the SDK polling thread. It changes no requests, cassette contents, output assertions, or production code.Exact full-module command executed (passed):
Temporary playback safety/timing plugin used for this run
The following was saved temporarily as
.git\cosmosdb_playback_guard.pyfor the command above and removed after validation. It is not part of the feature patch.The follow-up addresses the review's service-backed coverage gap; it changes only the existing SQL-container scenario and its recording, with no production changes. The existing computed-property unit tests are retained.
The SQL scenario seeds two populated computed properties (
normalizedNameandnameLength) with typed generated SDK models, then uses public CLI commands to update indexing policy, show the container independently, update TTL from 1000 to 2000, and show independently again. Each update/show asserts both exact names and queries, the requested index paths, and the expected TTL. The recording contains 40 real service interactions, including the pre-update GET, update PUT, completed-resource GET, and separate show GET for both changes. Its only HTTP error is the expected initialcontainer exists404; update requests succeeded. Subscription IDs are scrubbed and credential headers/common tokens were checked.Run from the repository root in the development virtual environment:
Result on the follow-up: 24 passed in 138.25 seconds, including the refreshed SQL scenario and both fleet playbacks.
Additional offline regression run:
Result: 21 passed, 2 deselected, 127 passing subtests in 3.63 seconds, covering numeric boundaries, omitted/null/empty values, typed request object graphs and serialization, attachment validation, inline/file input, help/examples, and public update/show mapping.
SQL live recording command already executed:
Result: 1 passed in 315.86 seconds. The resulting cassette passed the focused playback run above. Request/response inspection confirms both computed-property names/queries survive both updates and the subsequent independent shows; indexing paths and TTL changes persist in service responses.
The unchanged non-pooled cassette was recorded for the original port with:
Result at the original port: 1 passed in 109.51 seconds. Its stable-API create/show/delete and cleanup recording passed playback again on the follow-up.
Other validation:
azdev style cosmosdbpython -m compileall -q src\azure-cli\azure\cli\command_modules\cosmosdbgit diff --check 0fb575456532726e3c83aadb300957424dde8e9cazdev linter cosmosdbazure-mgmt-recoveryservicesbackup-passivestamp==1.0.0b1, whose installed wheel lacks its models. This is not a local full-linter pass.No violations found for linter rules.azdev scan)Exact native Cosmos DB-isolated linter invocation (passed)
Hosted CI must validate the new follow-up head. The successful checks reported for the previously reviewed head
4298fb33a41c75fbaa7882daa03c5ac99da298cbare not claimed as CI evidence for this commit. No Agent live-test dispatch was requested; the SQL recording above is author-run native test evidence.History Notes
[CosmosDB]
az cosmosdb sql container update: Fix loss of existing computed properties during container updates[CosmosDB]
az cosmosdb fleetspace create: Support non-pooled creation with omitted, null, or empty throughput pool configuration[CosmosDB]
az cosmosdb fleetspace: Fix throughput-bound and database account attachment input validationThis checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.