[Cognitive Services] az cognitiveservices account compute: Support compute cluster resources management#33759
Conversation
…eate/show/list/delete and bump azure-mgmt-cognitiveservices to 15.0.0b3 Cherry-picks the compute onboarding from achauhan-scc/azure-cli@compute (Amit Chauhan's Project Horizon work) and targets the public azure-mgmt-cognitiveservices 15.0.0b3 SDK on PyPI instead of the private ADO-feed build (2.84.0.dev3+foundry.prpr / 15.0.0b1.dev4+foundry.prpr) so this can ship in the official azure-cli release.
|
Hi @saanikaguptamicrosoft, |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Pull request overview
Adds a new preview az cognitiveservices account compute command group to manage Cognitive Services account compute resources, and updates the Cognitive Services management SDK dependency to a newer beta required for the feature.
Changes:
- Bump
azure-mgmt-cognitiveservicesdependency from15.0.0b2to15.0.0b3(setup + platform requirements). - Introduce
cognitiveservices account computecommands (create,delete,show,list) wired to new custom handlers and a new client factory. - Add CLI help text and history notes for the new command group.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/azure-cli/setup.py | Updates SDK dependency version constraint for Cognitive Services. |
| src/azure-cli/requirements.py3.windows.txt | Pins Cognitive Services SDK to 15.0.0b3 on Windows. |
| src/azure-cli/requirements.py3.Linux.txt | Pins Cognitive Services SDK to 15.0.0b3 on Linux. |
| src/azure-cli/requirements.py3.Darwin.txt | Pins Cognitive Services SDK to 15.0.0b3 on macOS. |
| src/azure-cli/HISTORY.rst | Documents the new preview command group and SDK bump. |
| src/azure-cli/azure/cli/command_modules/cognitiveservices/custom.py | Implements custom handlers for compute CRUD operations. |
| src/azure-cli/azure/cli/command_modules/cognitiveservices/commands.py | Registers the new cognitiveservices account compute command group and commands. |
| src/azure-cli/azure/cli/command_modules/cognitiveservices/_params.py | Adds parameters for the new command group (compute name + create args). |
| src/azure-cli/azure/cli/command_modules/cognitiveservices/_help.py | Adds help entries and examples for the new command group. |
| src/azure-cli/azure/cli/command_modules/cognitiveservices/_client_factory.py | Adds a client factory for computes operations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…mmands Matches the precedent set by PR Azure#33132 (managed-network) and PR Azure#33338 (managed-compute-deployment): every new preview command group under az cognitiveservices adds a missing_command_test_coverage exclusion so azdev linter passes in CI without requiring scenario-recording tests in the same PR.
…ates Contributors do not manually edit HISTORY.rst. Verified in the last 12 months on Azure/azure-cli dev only the release bot (Azure CLI Bot <azpycli@microsoft.com>) touches this file. Reference PRs Azure#33132 and Azure#33338 did not modify it. The release bot generates each version section from PR titles / History Notes at release cut time. Rely on the PR title / body 'History Notes' section to be picked up for the 2.89.0 release.
…, no_wait store_true, vm_priority default Copilot review comments 1-3 on PR Azure#33759: 1. Use get_location_type(self.cli_ctx) for --location so completion and az account list-locations integration work consistently (module convention, already used at _params.py lines 217, 617, 775). 2. Add action='store_true' to --no-wait so argparse treats it as a boolean flag; matches the existing no_wait argument at _params.py line 498 in this same module. 3. Change vm_priority default from 'Regular' (which did not match the help text advertising Dedicated/LowPriority) to None so the service applies its own default. Help text updated to say 'If omitted, the service default is used.' Comment 4 (missing scenario tests) is not addressed: reference PR Azure#33338 (managed-compute-deployment) shipped without scenario tests and is the established precedent for new preview command groups in this module. missing_command_test_coverage is already excluded in linter_exclusions.yml.
…re-mgmt-cognitiveservices 15.0.0b3 Between the private-feed SDK (15.0.0b1.dev4+foundry.prpr) and public PyPI 15.0.0b3, the 'location' field moved out of ComputeProperties and onto the outer Compute envelope. Amit's original code assumed the old shape and failed with: TypeError: ComputeProperties.__init__() got an unexpected keyword argument 'location' Move location= from ComputeProperties(...) to Compute(...). No CLI-facing arg surface changes (--location kept as-is); internal model construction only.
The prior commit 7e2e103 used 'git add -A' which swept the local .venv-env1-public-sdk/ (16k+ files) into the tree. Removed via 'git rm -r --cached'; files remain on disk locally. No effect on our compute onboarding changes.
…dry) from index The very first commit d6af1ef used 'git add -A' and swept BOTH local venvs (.venv-env1-public-sdk was removed in caff078, but .venv-env2-both-foundry remained). Removing via 'git rm -r --cached' now; files stay on disk locally. PR diff should now correctly show only the intended compute onboarding files (~10 files).
…ubclass) instead of abstract ComputeProperties
Second schema-drift catch on public azure-mgmt-cognitiveservices 15.0.0b3:
ComputeProperties is an abstract polymorphic base class discriminated by computeType. Instantiating it directly with pools=[...] fails at runtime with TypeError: ComputeProperties.__init__() got an unexpected keyword argument 'pools'. The concrete subclass for cluster creation is ClusterComputeProperties (which carries pools, subnet_arm_id, etc. and auto-sets computeType='Cluster').
Verified against the installed 15.0.0b3 SDK: issubclass(ClusterComputeProperties, ComputeProperties) is True; ClusterComputeProperties(pools=[]) succeeds and produces {'pools': [], 'computeType': 'Cluster'}.
Hardcoding the cluster path only for now; no --compute-type CLI flag needed since every current customer of 'az cognitiveservices account compute create' is creating a cluster.
… for RP acceptance The RP for cluster-type compute creation returns HTTP 400 'The Location field is required' when location is only on the outer Compute envelope. Setting location inside the properties block (matching the private-feed schema) satisfies the validator. Location is kept on the outer Compute as well for correctness with the top-level ARM tracked-resource model. The public 15.0.0b3 SDK ClusterComputeProperties class does not declare location as an accepted kwarg, so we set it via the underlying dict-backed model. Once Swarup's SDK update adds it as a first-class kwarg, we can switch to the cleaner constructor form.
…lusterComputeProperties as first-class kwarg Removes the 15.0.0b3 workaround (setting location on outer Compute + dict-injection into properties) in favor of the shape that Swarup's fixed SDK build supports: location declared as a proper kwarg on ClusterComputeProperties. SDK pin stays at ~=15.0.0b3 for now; a separate PR will bump to ~=15.0.0b4 once that release is on public PyPI.
…e - matches SDK owner's tested shape Reverts the earlier attempt to declare location as a first-class kwarg on ClusterComputeProperties. That kwarg is not present in the shipping SDK (15.0.0b3 or Swarup's b4 build) - the class rejects it with TypeError. The service requires location BOTH on the outer Compute envelope AND inside the properties block (per the SDK owner's own validated sample). Setting it in the underlying dict-backed model satisfies both placements. Validated end-to-end against the SDK owner's build: azure.mgmt.cognitiveservices.computes.begin_create_or_update accepted the request; provisioningState progressed to Accepted (subsequent downstream Failed state is a provisioning-side issue independent of the request shape).
The compute_delete custom function already accepts no_wait=False but the CLI arg context only declared --no-wait under 'compute create'. Adding the missing argument_context so the flag is discoverable and functional for delete.
…ete (canonical pattern)
The previous approach of manually declaring c.argument('no_wait', ...) worked for create but silently failed for delete because azure-cli filters no_wait from auto-registration unless supports_no_wait=True is set on the command.
Switching to the canonical pattern: pass supports_no_wait=True on g.custom_command for both create and delete. The framework now auto-injects --no-wait (and --poll-interval) with correct wiring. Removes the manual c.argument('no_wait', ...) declarations from _params.py since they are no longer needed.
|
cognitiveservices |
|
It seems the latest version of |
|
Hi @yanzhudd |
Adds test_compute.py with 9 unit tests covering all four commands in the new 'az cognitiveservices account compute' group. Uses mock.Mock() for the SDK client - no live Azure resources required. Coverage: - create: wire-payload shape (location on outer Compute AND inside properties, computeType=Cluster discriminator, pool structure); vm_priority passthrough and default-omit behavior; no_wait branch returns poller directly; default branch calls .result(). - list, show: client pass-through with correct positional args. - delete: client pass-through; no_wait branch returns poller; default branch calls .result(). Addresses reviewer request from Ethan Yang (@YangAn-microsoft) to add test coverage for the new commands.
… group Adds two @live_only()-decorated ScenarioTest methods covering the full compute command surface end to end: - test_cognitiveservices_compute_list_empty: fresh AI Foundry account, 'compute list' returns []. - test_cognitiveservices_compute_create_show_delete: create compute (--no-wait), show, list, delete (--no-wait), tear down account. Both tests are decorated at the class level with @live_only() (canonical pattern established by test_agent.py in this module), which means they are automatically skipped in CI/playback runs and only execute when AZURE_TEST_RUN_LIVE=True is set. This avoids the need for recorded VCR YAMLs, which cannot be reliably captured on the current pytest/testsdk combination in this environment. Actual CI regression coverage is via the 9 mock-based unit tests in CognitiveServicesComputeUnitTests, which lock the wire-payload shape (including the required dual-placement of 'location' on outer Compute + inside properties) and validate no_wait/vm_priority behaviour. Addresses reviewer request (Ethan Yang) to add scenario-level test coverage per doc/authoring_tests.md.
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
…om compute funcs Copilot review pointed out that with supports_no_wait=True on the command_group, the CLI framework handles wait-vs-no-wait itself via its LongRunningOperation wrapper. Calling poller.result() in compute_begin_create_or_update and compute_delete bypasses that wrapper (loses consistent progress reporting) and duplicates the no-wait logic. Both custom functions now just return the poller. Framework does the rest. Unit tests updated: replaced the two no_wait / default-wait tests per function with a single 'returns poller without waiting' assertion each. All 9 unit tests still pass.
az cognitiveservices account compute: Support compute cluster resources management
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
…mpute custom funcs After removing the poller.result() branch (framework handles wait via supports_no_wait=True), the 'no_wait' parameter is no longer read inside compute_begin_create_or_update and compute_delete. Keeping the parameter in the signature is safe (framework may still pass it) and lower-risk than removing it. Adding pylint disable comments to fix azdev style CI.
|
/azp run |
| Command 'run |
…om funcs Adopts the standard pattern used by 24 other command_modules in azure-cli (vm, aks, cosmosdb, etc.): route through azure.cli.core.util.sdk_no_wait which forwards polling=False to the SDK when no_wait is true, letting the framework's LongRunningOperation wrapper handle the wait behaviour on the false path. Wire behaviour is identical to the previous 'just return poller' shape; the difference is that no_wait is now used (satisfies pylint W0613: unused-argument that broke CI) and the intent is documented via the well-known helper.
|
/azp run |
| Command 'run |
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
…itiveservices 15.0.0b4 api-version SDK 15.0.0b4 uses api-version 2026-05-15-preview; all 25 existing scenario-test recording YAMLs were captured against the previous 2026-03-15-preview and now fail with VCR CannotOverwriteExistingCassetteException on the URL query-string matcher. Mechanical replacement of 2026-03-15-preview -> 2026-05-15-preview across all cognitiveservices YAMLs (182 URL replacements, 25 files). The recorded response bodies are unchanged - the api-version is a request-side header/query only, so this is safe. Matches the precedent from PRs Azure#33132 and Azure#33338 which also refreshed the module's recording YAMLs when bumping the SDK.
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
Dependencies
Merge and release of this SDK PR: Azure/azure-sdk-for-python#48096
Related command
az cognitiveservices account compute create --name jayant-westcentralus -g rg-jayant --compute-name test-compute-chhavi --instance-type "Standard_D64_v3" --node-count 1 --pool-name "pool-test-123" --location "westcentralus" --subscription 696debc0-8b66-4d84-87b1-39f43917d76caz cognitiveservices account compute list -n jayant-westcentralus -g rg-jayant --subscription 696debc0-8b66-4d84-87b1-39f43917d76cDescription
achauhan-scc/azure-cli@computeand targets the publicazure-mgmt-cognitiveservices==15.0.0b4SDK on PyPI (bumped from15.0.0b2) instead of the private ADO-feed build (15.0.0b1.dev4+foundry.prpr). This unblocks shipping the commands in the official azure-cli release so customers no longer need read access to the private ADO feed.supports_no_wait=Truepattern.is_preview=Trueon the command group is the appropriate surface tag — matches the pattern in {Cognitive Services} Upgrade azure-mgmt-cognitiveservices to 15.0.0b1 and add managed-network commands #33132 and {Cognitive Services} Manage Compute Deployment Support #33338.Testing Guide
CLI test setup: https://github.com/Azure/azure-cli/blob/dev/doc/configuring_your_machine.md
The CLI test is done against this SDK PR: [cognitiveservices] Unblock managed compute creation - fix misleading 202 / AuthorizationFailed errors azure-sdk-for-python#48096
Confirming testing env (both SDK and CLI are in editable mode):
History Notes
This 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.
🤖 PR Validation —⚠️ Review suggested