Skip to content

[Cognitive Services] az cognitiveservices account compute: Support compute cluster resources management#33759

Merged
necusjz merged 21 commits into
Azure:devfrom
saanikaguptamicrosoft:saanika/compute-public-sdk
Jul 24, 2026
Merged

[Cognitive Services] az cognitiveservices account compute: Support compute cluster resources management#33759
necusjz merged 21 commits into
Azure:devfrom
saanikaguptamicrosoft:saanika/compute-public-sdk

Conversation

@saanikaguptamicrosoft

@saanikaguptamicrosoft saanikaguptamicrosoft commented Jul 21, 2026

Copy link
Copy Markdown
Member

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-39f43917d76c
  • az cognitiveservices account compute list -n jayant-westcentralus -g rg-jayant --subscription 696debc0-8b66-4d84-87b1-39f43917d76c

Description

  • Onboards a new (private preview) command group az cognitiveservices account compute with create, show, list, delete for managing compute cluster resources on Cognitive Services (AI Foundry) accounts. Cherry-picks the code from achauhan-scc/azure-cli@compute and targets the public azure-mgmt-cognitiveservices==15.0.0b4 SDK on PyPI (bumped from 15.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.
  • Also adds --no-wait support for both create and delete via the canonical supports_no_wait=True pattern.
  • Access to the underlying API is still gated server-side (private preview allow-list on the RP), so is_preview=True on 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.
  • Scenario tests for all 4 commands added - docs reference

Testing Guide

image
  • Create command (failed due to quota issue by server as expected)
image image
  • Show command
image
  • List command
image
  • Delete command
image image

History Notes


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

🤖 PR Validation — ⚠️ Review suggested

Breaking Changes Tests
⚠️ None ️✔️ 130/130
⚠️AzureCLI-BreakingChangeTest
⚠️cognitiveservices
rule cmd_name rule_message suggest_message
⚠️ 1011 - SubgroupAdd cognitiveservices account compute sub group cognitiveservices account compute added

…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.
Copilot AI review requested due to automatic review settings July 21, 2026 09:29
@saanikaguptamicrosoft
saanikaguptamicrosoft requested review from a team as code owners July 21, 2026 09:29
@azure-client-tools-bot-prd

Copy link
Copy Markdown

Hi @saanikaguptamicrosoft,
Since the current milestone time is less than 7 days, this pr will be reviewed in the next milestone.

@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

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-cognitiveservices dependency from 15.0.0b2 to 15.0.0b3 (setup + platform requirements).
  • Introduce cognitiveservices account compute commands (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.

Comment thread src/azure-cli/azure/cli/command_modules/cognitiveservices/_params.py Outdated
Comment thread src/azure-cli/azure/cli/command_modules/cognitiveservices/_params.py Outdated
Comment thread src/azure-cli/azure/cli/command_modules/cognitiveservices/custom.py Outdated
Comment thread src/azure-cli/azure/cli/command_modules/cognitiveservices/commands.py Outdated
…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.
@saanikaguptamicrosoft saanikaguptamicrosoft changed the title {Cognitive Services} az cognitiveservices account compute: Onboard cr… az cognitiveservices account compute: Onboard create/show/list/delete Jul 21, 2026
…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.
@yonzhan
yonzhan requested a review from necusjz July 21, 2026 22:17
@yonzhan

yonzhan commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

cognitiveservices

@yanzhudd

Copy link
Copy Markdown
Contributor

It seems the latest version of azure-mgmt-cognitiveservices package is till 15.0.0b3, rather than 15.0.0b4:
https://pypi.org/project/azure-mgmt-cognitiveservices/#history
Please note Azure CLI can only use an SDK package after it has been publicly published.

@saanikaguptamicrosoft

Copy link
Copy Markdown
Member Author

Hi @yanzhudd
The 15.0.0b4 version of SDK just got released 15 minutes back. We were tracking its release in a separate thread, hence used the unreleased version here. I've retriggered the failed CI - they should pass now since SDK is released.

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 10 out of 10 changed files in this pull request and generated 2 comments.

Comment thread src/azure-cli/azure/cli/command_modules/cognitiveservices/custom.py Outdated
Comment thread src/azure-cli/azure/cli/command_modules/cognitiveservices/custom.py Outdated
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.
@necusjz

necusjz commented Jul 22, 2026

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
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.
@necusjz necusjz changed the title az cognitiveservices account compute: Onboard create/show/list/delete [Cognitive Services] az cognitiveservices account compute: Support compute cluster resources management Jul 22, 2026
@necusjz

necusjz commented Jul 22, 2026

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
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.
@a0x1ab

a0x1ab commented Jul 22, 2026

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
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.
@a0x1ab

a0x1ab commented Jul 22, 2026

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Command 'run

@necusjz

necusjz commented Jul 23, 2026

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
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.
@a0x1ab

a0x1ab commented Jul 24, 2026

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

@necusjz
necusjz merged commit 563dd51 into Azure:dev Jul 24, 2026
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants