Skip to content

{aimanager} Shorten modeldeployment args and list across namespaces - #10346

Merged
Liqian Luo (circy9) merged 12 commits into
Azure:mainfrom
circy9:aimanager-rename-namespace-arg
Sep 16, 2026
Merged

Liqian Luo (circy9) merged 12 commits into
Azure:mainfrom
circy9:aimanager-rename-namespace-arg

Conversation

@circy9

@circy9 Liqian Luo (circy9) commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

🤖 PR Validation — ❌ Action needed

Breaking Changes
❌ 1
❌Azure CLI Extensions Breaking Change Test
❌aimanager
rule cmd_name rule_message suggest_message
❌ 1010 - ParaPropUpdate aimanager modelsource add cmd aimanager modelsource add update parameter ai_manager_name: updated property options from ['--aimanager-name', '--manager', '-m'] to ['--aimanager', '--manager', '-m'] please change property options from ['--aimanager', '--manager', '-m'] to ['--aimanager-name', '--manager', '-m'] for parameter ai_manager_name of cmd aimanager modelsource add
❌ 1010 - ParaPropUpdate aimanager modelsource delete cmd aimanager modelsource delete update parameter ai_manager_name: updated property options from ['--aimanager-name', '--manager', '-m'] to ['--aimanager', '--manager', '-m'] please change property options from ['--aimanager', '--manager', '-m'] to ['--aimanager-name', '--manager', '-m'] for parameter ai_manager_name of cmd aimanager modelsource delete
❌ 1010 - ParaPropUpdate aimanager modelsource list cmd aimanager modelsource list update parameter ai_manager_name: updated property options from ['--aimanager-name', '--manager', '-m'] to ['--aimanager', '--manager', '-m'] please change property options from ['--aimanager', '--manager', '-m'] to ['--aimanager-name', '--manager', '-m'] for parameter ai_manager_name of cmd aimanager modelsource list
❌ 1010 - ParaPropUpdate aimanager modelsource show cmd aimanager modelsource show update parameter ai_manager_name: updated property options from ['--aimanager-name', '--manager', '-m'] to ['--aimanager', '--manager', '-m'] please change property options from ['--aimanager', '--manager', '-m'] to ['--aimanager-name', '--manager', '-m'] for parameter ai_manager_name of cmd aimanager modelsource show
❌ 1010 - ParaPropUpdate aimanager modelsource update cmd aimanager modelsource update update parameter ai_manager_name: updated property options from ['--aimanager-name', '--manager', '-m'] to ['--aimanager', '--manager', '-m'] please change property options from ['--aimanager', '--manager', '-m'] to ['--aimanager-name', '--manager', '-m'] for parameter ai_manager_name of cmd aimanager modelsource update
❌ 1010 - ParaPropUpdate aimanager modelsource wait cmd aimanager modelsource wait update parameter ai_manager_name: updated property options from ['--aimanager-name', '--manager', '-m'] to ['--aimanager', '--manager', '-m'] please change property options from ['--aimanager', '--manager', '-m'] to ['--aimanager-name', '--manager', '-m'] for parameter ai_manager_name of cmd aimanager modelsource wait
❌ 1010 - ParaPropUpdate aimanager namespace add cmd aimanager namespace add update parameter ai_manager_name: updated property options from ['--aimanager-name', '--manager', '-m'] to ['--aimanager', '--manager', '-m'] please change property options from ['--aimanager', '--manager', '-m'] to ['--aimanager-name', '--manager', '-m'] for parameter ai_manager_name of cmd aimanager namespace add
❌ 1010 - ParaPropUpdate aimanager namespace delete cmd aimanager namespace delete update parameter ai_manager_name: updated property options from ['--aimanager-name', '--manager', '-m'] to ['--aimanager', '--manager', '-m'] please change property options from ['--aimanager', '--manager', '-m'] to ['--aimanager-name', '--manager', '-m'] for parameter ai_manager_name of cmd aimanager namespace delete
❌ 1010 - ParaPropUpdate aimanager namespace get-credentials cmd aimanager namespace get-credentials update parameter ai_manager_name: updated property options from ['--aimanager-name', '--manager', '-m'] to ['--aimanager', '--manager', '-m'] please change property options from ['--aimanager', '--manager', '-m'] to ['--aimanager-name', '--manager', '-m'] for parameter ai_manager_name of cmd aimanager namespace get-credentials
❌ 1010 - ParaPropUpdate aimanager namespace list cmd aimanager namespace list update parameter ai_manager_name: updated property options from ['--aimanager-name', '--manager', '-m'] to ['--aimanager', '--manager', '-m'] please change property options from ['--aimanager', '--manager', '-m'] to ['--aimanager-name', '--manager', '-m'] for parameter ai_manager_name of cmd aimanager namespace list
❌ 1010 - ParaPropUpdate aimanager namespace list-accesskeys cmd aimanager namespace list-accesskeys update parameter ai_manager_name: updated property options from ['--aimanager-name', '--manager', '-m'] to ['--aimanager', '--manager', '-m'] please change property options from ['--aimanager', '--manager', '-m'] to ['--aimanager-name', '--manager', '-m'] for parameter ai_manager_name of cmd aimanager namespace list-accesskeys
❌ 1010 - ParaPropUpdate aimanager namespace modeldeployment add cmd aimanager namespace modeldeployment add update parameter ai_manager_name: updated property options from ['--aimanager-name', '--manager', '-m'] to ['--aimanager', '--manager', '-m'] please change property options from ['--aimanager', '--manager', '-m'] to ['--aimanager-name', '--manager', '-m'] for parameter ai_manager_name of cmd aimanager namespace modeldeployment add
❌ 1010 - ParaPropUpdate aimanager namespace modeldeployment add cmd aimanager namespace modeldeployment add update parameter namespace_name: updated property options from ['--namespace-name', '--ns'] to ['--namespace', '--ns'] please change property options from ['--namespace', '--ns'] to ['--namespace-name', '--ns'] for parameter namespace_name of cmd aimanager namespace modeldeployment add
❌ 1010 - ParaPropUpdate aimanager namespace modeldeployment delete cmd aimanager namespace modeldeployment delete update parameter ai_manager_name: updated property options from ['--aimanager-name', '--manager', '-m'] to ['--aimanager', '--manager', '-m'] please change property options from ['--aimanager', '--manager', '-m'] to ['--aimanager-name', '--manager', '-m'] for parameter ai_manager_name of cmd aimanager namespace modeldeployment delete
❌ 1010 - ParaPropUpdate aimanager namespace modeldeployment delete cmd aimanager namespace modeldeployment delete update parameter namespace_name: updated property options from ['--namespace-name', '--ns'] to ['--namespace', '--ns'] please change property options from ['--namespace', '--ns'] to ['--namespace-name', '--ns'] for parameter namespace_name of cmd aimanager namespace modeldeployment delete
❌ 1010 - ParaPropUpdate aimanager namespace modeldeployment list cmd aimanager namespace modeldeployment list update parameter ai_manager_name: updated property options from ['--aimanager-name', '--manager', '-m'] to ['--aimanager', '--manager', '-m'] please change property options from ['--aimanager', '--manager', '-m'] to ['--aimanager-name', '--manager', '-m'] for parameter ai_manager_name of cmd aimanager namespace modeldeployment list
❌ 1010 - ParaPropUpdate aimanager namespace modeldeployment list cmd aimanager namespace modeldeployment list update parameter namespace_name: updated property options from ['--namespace-name', '--ns'] to ['--namespace', '--ns'] please change property options from ['--namespace', '--ns'] to ['--namespace-name', '--ns'] for parameter namespace_name of cmd aimanager namespace modeldeployment list
❌ 1010 - ParaPropUpdate aimanager namespace modeldeployment show cmd aimanager namespace modeldeployment show update parameter ai_manager_name: updated property options from ['--aimanager-name', '--manager', '-m'] to ['--aimanager', '--manager', '-m'] please change property options from ['--aimanager', '--manager', '-m'] to ['--aimanager-name', '--manager', '-m'] for parameter ai_manager_name of cmd aimanager namespace modeldeployment show
❌ 1010 - ParaPropUpdate aimanager namespace modeldeployment show cmd aimanager namespace modeldeployment show update parameter namespace_name: updated property options from ['--namespace-name', '--ns'] to ['--namespace', '--ns'] please change property options from ['--namespace', '--ns'] to ['--namespace-name', '--ns'] for parameter namespace_name of cmd aimanager namespace modeldeployment show
❌ 1010 - ParaPropUpdate aimanager namespace modeldeployment update cmd aimanager namespace modeldeployment update update parameter ai_manager_name: updated property options from ['--aimanager-name', '--manager', '-m'] to ['--aimanager', '--manager', '-m'] please change property options from ['--aimanager', '--manager', '-m'] to ['--aimanager-name', '--manager', '-m'] for parameter ai_manager_name of cmd aimanager namespace modeldeployment update
❌ 1010 - ParaPropUpdate aimanager namespace modeldeployment update cmd aimanager namespace modeldeployment update update parameter namespace_name: updated property options from ['--namespace-name', '--ns'] to ['--namespace', '--ns'] please change property options from ['--namespace', '--ns'] to ['--namespace-name', '--ns'] for parameter namespace_name of cmd aimanager namespace modeldeployment update
❌ 1010 - ParaPropUpdate aimanager namespace modeldeployment wait cmd aimanager namespace modeldeployment wait update parameter ai_manager_name: updated property options from ['--aimanager-name', '--manager', '-m'] to ['--aimanager', '--manager', '-m'] please change property options from ['--aimanager', '--manager', '-m'] to ['--aimanager-name', '--manager', '-m'] for parameter ai_manager_name of cmd aimanager namespace modeldeployment wait
❌ 1010 - ParaPropUpdate aimanager namespace modeldeployment wait cmd aimanager namespace modeldeployment wait update parameter namespace_name: updated property options from ['--namespace-name', '--ns'] to ['--namespace', '--ns'] please change property options from ['--namespace', '--ns'] to ['--namespace-name', '--ns'] for parameter namespace_name of cmd aimanager namespace modeldeployment wait
❌ 1010 - ParaPropUpdate aimanager namespace rotate-accesskeys cmd aimanager namespace rotate-accesskeys update parameter ai_manager_name: updated property options from ['--aimanager-name', '--manager', '-m'] to ['--aimanager', '--manager', '-m'] please change property options from ['--aimanager', '--manager', '-m'] to ['--aimanager-name', '--manager', '-m'] for parameter ai_manager_name of cmd aimanager namespace rotate-accesskeys
❌ 1010 - ParaPropUpdate aimanager namespace show cmd aimanager namespace show update parameter ai_manager_name: updated property options from ['--aimanager-name', '--manager', '-m'] to ['--aimanager', '--manager', '-m'] please change property options from ['--aimanager', '--manager', '-m'] to ['--aimanager-name', '--manager', '-m'] for parameter ai_manager_name of cmd aimanager namespace show
❌ 1010 - ParaPropUpdate aimanager namespace update cmd aimanager namespace update update parameter ai_manager_name: updated property options from ['--aimanager-name', '--manager', '-m'] to ['--aimanager', '--manager', '-m'] please change property options from ['--aimanager', '--manager', '-m'] to ['--aimanager-name', '--manager', '-m'] for parameter ai_manager_name of cmd aimanager namespace update
❌ 1010 - ParaPropUpdate aimanager namespace wait cmd aimanager namespace wait update parameter ai_manager_name: updated property options from ['--aimanager-name', '--manager', '-m'] to ['--aimanager', '--manager', '-m'] please change property options from ['--aimanager', '--manager', '-m'] to ['--aimanager-name', '--manager', '-m'] for parameter ai_manager_name of cmd aimanager namespace wait
⚠️ 1009 - ParaPropRemove aimanager namespace modeldeployment list cmd aimanager namespace modeldeployment list update parameter namespace_name: removed property required=True

Summary

Preview-usability improvements to the az aimanager command group, driven by bug-bash feedback. Three changes:

  1. Rename --namespace-name → --namespace (on aimanager namespace modeldeployment). The --ns short alias is unchanged. (AB#39633340)
  2. Rename --aimanager-name → --aimanager (on aimanager modelsource, aimanager namespace, and aimanager namespace modeldeployment). The --manager / -m aliases are unchanged. (AB#39633340)
  3. List model deployments across namespaces on aimanager namespace modeldeployment list: --namespace/--ns is now optional. When omitted, deployments are listed across all readable namespaces of the AI Manager — following the az ... list convention (list-by-resource-group vs list-by-subscription) and mirroring kubectl get pods --all-namespaces. Because the model_deployments SDK has no cross-namespace list operation, the command enumerates the AI Manager's namespaces (one list_by_ai_manager call, paged) and fans out one list_by_ai_manager_namespace call per namespace, aggregating the results. Two permissions are involved and the help documents both: listing namespaces requires namespace read on the AI Manager, and listing deployments in each namespace requires model deployment read for that namespace (granted on the namespace, or inherited from the AI Manager). If namespaces can't be listed, an UnauthorizedError names the AI-Manager namespace-read requirement. Namespaces the caller can't read deployments in (401/403) are skipped with a per-namespace warning so a partially-authorized caller still sees what they can read; if the caller is denied on every namespace, an UnauthorizedError names the per-namespace model-deployment-read requirement (without suggesting --namespace, since scoping to one namespace would fail too). The namespace-enumeration error does suggest --namespace/--ns for a single namespace. The list table derives the Namespace column from each resource id, so the aggregated view groups correctly. (AB#39633378)

Files changed

  • azext_aimanager/_params.py — renamed option lists; made namespace_name optional in the list context.
  • azext_aimanager/custom.py — list_modeldeployment lists across all readable namespaces when no namespace is given, skipping forbidden ones.
  • azext_aimanager/_help.py — updated examples; added a cross-namespace example.
  • azext_aimanager/tests/latest/ — updated the options_list assertion and scenario tests; added single-namespace, cross-namespace aggregation, skip-forbidden, and reraise-non-auth unit tests. Also made several pre-existing duplicate test method names unique so azdev test --discover (CI) passes.
  • setup.py — version bump to 1.5.4b1.
  • HISTORY.rst — changelog entries.

Breaking changes

Flagged by the breaking-change validator:

  • Rule 1010 (ParaPropUpdate) — --namespace-name and --aimanager-name removed as option strings (the two renames).
  • Rule 1009 (ParaPropRemove) — namespace_name on ... modeldeployment list is no longer required=True.

These breaking changes are acceptable: the aimanager extension is still in preview and has not been launched — the command group is marked is_preview=True and there are no GA'd consumers depending on the old option names or on the namespace being required. Making these changes now, before launch, avoids carrying the overly long names forever and aligns list with the standard az ... list scoping convention. The most-used aliases (--ns, --manager/-m) are preserved.

Testing

Validated locally in an azdev venv (dev extension active) and against a live preview subscription with real resources (two namespaces, one deployment each). See PR comments for full live command output.

  • azdev test azext_aimanager --discover --series — 81 passed (CI-equivalent discovery path)
  • azdev style aimanager — pylint + flake8 PASSED
  • azdev linter aimanager — no violations
  • Live: renames work, old option strings rejected, aliases preserved
  • Live: --namespace ns2 scopes to one namespace; omitting --namespace aggregates across all namespaces

Fixes AB#39633340
Fixes AB#39633378

Shorten the modeldeployment namespace argument from --namespace-name to
--namespace (the --ns alias is unchanged), per bug-bash feedback that
--namespace-name is too long.

Fixes AB#39633340
Copilot AI lite review requested due to automatic review settings September 16, 2026 00:19
@azure-client-tools-bot-prd

Copy link
Copy Markdown

Hi Liqian Luo (@circy9),
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 pyproject.toml (or setup.py, if the extension has not migrated yet) as well.

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.

🟡 Changes recommended

An existing unit test still expects --namespace-name and must be updated.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Renames the AI Manager model deployment option to --namespace while retaining --ns.

Changes:

  • Updates argument registration, help examples, and scenario tests.
  • Bumps the extension version to 1.5.4b1.
  • Adds release history.
  • An existing unit test still expects --namespace-name.
File summaries
File Description
src/aimanager/setup.py Bumps extension version.
src/aimanager/HISTORY.rst Documents the renamed option.
src/aimanager/azext_aimanager/tests/latest/test_modeldeployment_scenario.py Updates scenario commands.
src/aimanager/azext_aimanager/_params.py Registers --namespace and --ns.
src/aimanager/azext_aimanager/_help.py Updates command examples.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Reflect the --namespace-name -> --namespace rename in the
test_modeldeployment options_list assertion.
@circy9

Copy link
Copy Markdown
Contributor Author

Local test results ✅

Ran the change in an azdev venv with the dev extension active (whl copy removed), against a live subscription with a real deployment.

Live CLI commands (sub AKS INT/Staging Test, rg aimtest-0915, aimanager aimbase0915, namespace ns1)

1. Old --namespace-name is correctly rejected:

$ az aimanager namespace modeldeployment list -g aimtest-0915 -m aimbase0915 --namespace-name ns1
ERROR: the following arguments are required: --namespace/--ns

2. New --namespace works (-o table):

$ az aimanager namespace modeldeployment list -g aimtest-0915 -m aimbase0915 --namespace ns1 -o table
Namespace    Name    ProvisioningState    Replicas    Age    ModelId                Endpoint
-----------  ------  -------------------  ----------  -----  ---------------------  ----------------------------------
ns1          md1     Succeeded            1/1         4h53m  google/gemma-4-E4B-it  https://ns1.<...>.aksapp.io/v1

3. --ns alias still works — identical output to (2).

4. show --namespace ns1 -n md1 — renders correctly, identical row.

5. Help output:

--aimanager-name --manager -m [Required] : The name of the AI Manager resource.
--namespace --ns              [Required] : The name of the AI Manager namespace.
--resource-group -g           [Required] : Name of resource group. ...

azdev checks

Check Result
azdev linter aimanager ✅ No violations
azdev style aimanager (pylint + flake8) ✅ PASSED
azdev test aimanager --series ✅ 75 passed

Note: pushed a follow-up commit updating the test_modeldeployment options_list assertion to match the renamed flag.

Shorten the AI Manager name argument from --aimanager-name to --aimanager
across modelsource, namespace and modeldeployment command groups. The
--manager and -m aliases are unchanged.
@circy9

Copy link
Copy Markdown
Contributor Author

Local test results — --aimanager-name → --aimanager ✅

Added a second rename in this PR: --aimanager-name shortened to --aimanager across the modelsource, namespace, and namespace modeldeployment command groups. The --manager / -m aliases are unchanged.

Live CLI commands (sub AKS INT/Staging Test, rg aimtest-0915, aimanager aimbase0915, namespace ns1)

1. Old --aimanager-name is correctly rejected:

$ az aimanager namespace modeldeployment list -g aimtest-0915 --aimanager-name aimbase0915 --namespace ns1
ERROR: the following arguments are required: --aimanager/--manager/-m

2. New --aimanager works (-o table):

$ az aimanager namespace modeldeployment list -g aimtest-0915 --aimanager aimbase0915 --namespace ns1 -o table
Namespace    Name    ProvisioningState    Replicas    Age    ModelId                Endpoint
-----------  ------  -------------------  ----------  -----  ---------------------  ----------------------------------
ns1          md1     Succeeded            1/1         4h58m  google/gemma-4-E4B-it  https://ns1.<...>.aksapp.io/v1

3. -m alias still works — identical output.

4. Help output:

--aimanager --manager -m [Required] : The name of the AI Manager resource.
--namespace --ns         [Required] : The name of the AI Manager namespace.
--resource-group -g      [Required] : Name of resource group. ...

azdev checks

Check Result
azdev linter aimanager ✅ No violations
azdev style aimanager (pylint + flake8) ✅ PASSED
azdev test aimanager --series ✅ 75 passed

Support listing model deployments across all readable namespaces of an
AI Manager. Callers must specify exactly one of --namespace/--ns or
--all-namespaces/-A; a validator enforces this. --all-namespaces
enumerates namespaces via the namespaces client and aggregates the
per-namespace deployment lists. The list table already derives the
Namespace column from each resource id, so the cross-namespace view
renders correctly.
@yonzhan

Copy link
Copy Markdown
Collaborator

aimanager

@circy9

Liqian Luo (circy9) commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor Author

New feature + local test results — --all-namespaces / -A ✅

Updated: re-ran with a second namespace/deployment (ns2 / md2) so the cross-namespace aggregation is now demonstrated with more than one namespace.

Added --all-namespaces / -A to az aimanager namespace modeldeployment list. Callers must now specify exactly one of --namespace/--ns or --all-namespaces/-A (enforced by a validator). --all-namespaces enumerates the AI Manager's namespaces and aggregates their deployments (the model_deployments SDK only exposes list_by_ai_manager_namespace, so there is no single server-side cross-namespace call). The list table already derives the Namespace column from each resource id, so the aggregated view groups correctly.

Live CLI (sub AKS INT/Staging Test, rg aimtest-0915, aimanager aimbase0915)

Test AI Manager now has two namespaces, each with one deployment:

$ az aimanager namespace list -g aimtest-0915 --aimanager aimbase0915 -o table
Name    ProvisioningState    Age    Labels
------  -------------------  -----  ---------
ns1     Succeeded            5h21m  team=test
ns2     Succeeded            12m

1. Neither flag → rejected:

$ az aimanager namespace modeldeployment list -g aimtest-0915 --aimanager aimbase0915
ERROR: Specify --namespace/--ns to list deployments in one namespace, or --all-namespaces/-A to list across all readable namespaces.

2. Both flags → rejected:

$ ... --namespace ns1 --all-namespaces
ERROR: Specify either --namespace/--ns or --all-namespaces/-A, not both.

3. --namespace ns2 (scoped to one namespace — returns only md2):

Namespace    Name    ProvisioningState    Replicas    Age    ModelId                Endpoint
-----------  ------  -------------------  ----------  -----  ---------------------  ----------------------------------
ns2          md2     Succeeded            1/1         11m    google/gemma-4-E4B-it  https://ns2.<...>.aksapp.io/v1

4. --all-namespaces (aggregates both namespaces):

Namespace    Name    ProvisioningState    Replicas    Age    ModelId                Endpoint
-----------  ------  -------------------  ----------  -----  ---------------------  ----------------------------------
ns1          md1     Succeeded            1/1         5h18m  google/gemma-4-E4B-it  https://ns1.<...>.aksapp.io/v1
ns2          md2     Succeeded            1/1         10m    google/gemma-4-E4B-it  https://ns2.<...>.aksapp.io/v1

5. -A — identical two-row aggregated output.

azdev checks

Check Result
azdev linter aimanager ✅ No violations
azdev style aimanager (pylint + flake8) ✅ PASSED
azdev test aimanager --series ✅ 80 passed (5 new: scope validator x4 + all-namespaces aggregation)

Clarify that list_by_ai_manager is invoked once (returning a paged
iterator) and list_by_ai_manager_namespace is fanned out per namespace,
in response to PR review.
@circy9 Liqian Luo (circy9) changed the title {aimanager} Rename --namespace-name to --namespace {aimanager} Shorten --namespace-name/--aimanager-name and add --all-namespaces to modeldeployment list Sep 16, 2026
@circy9 Liqian Luo (circy9) changed the title {aimanager} Shorten --namespace-name/--aimanager-name and add --all-namespaces to modeldeployment list {aimanager} Shorten modeldeployment args and add list --all-namespaces Sep 16, 2026
Comment thread src/aimanager/HISTORY.rst Resolved
CI runs `azdev test --discover`, which requires globally unique test
method names across the whole azext_aimanager module. Several pre-existing
methods collided across test classes/modules, failing the Integration
Tests job. Rename the duplicated table-format methods (per resource type),
the aimodel validator methods, and the aimanager scenario method (with its
recording) so discovery succeeds.
@circy9

Copy link
Copy Markdown
Contributor Author

CI fix: Integration Tests failure (duplicate test method names)

The Integration Tests / Build Tests jobs failed on azdev test --discover, which requires globally unique test method names across the entire azext_aimanager module. The failure was not in this PR's new logic — it was a set of pre-existing name collisions in test files this PR did not originally touch:

  • test_aimanager_format.py — TestAIManagerTableFormat, TestNamespaceTableFormat, and TestModelDeploymentTableFormat all defined test_table_format_columns / _values / _missing_fields / _null_properties / test_list_table_format.
  • test_aimodel.py vs test_modelsource.py — both defined test_valid_name / test_missing_name_is_allowed / test_blank_name_is_rejected.
  • test_aimanager_scenario.py::test_aimanager collided with the test_aimanager.py module name.

(My local runs used azdev test --series without --discover, so they passed and didn't surface this.)

Fix (commit f0920cb): renamed the duplicated methods to be unique — table-format methods suffixed per resource type (_namespace / _modeldeployment), aimodel validator methods suffixed _aimodel, and the scenario method renamed test_aimanager → test_aimanager_crud (with its recording recordings/test_aimanager.yaml → test_aimanager_crud.yaml). No production code or test assertions changed.

Verified locally with the CI-equivalent command:

$ azdev test azext_aimanager --discover --series
============================= 80 passed =============================

azdev linter / azdev style remain clean.

Per PR review, follow the `az ... list` convention: instead of requiring
one of --namespace/--all-namespaces, make --namespace/--ns optional and
list across all readable namespaces when it is omitted (mirroring
`kubectl get pods --all-namespaces`). Drop --all-namespaces/-A and the
exactly-one-of validator.

Also handle partial authorization in the cross-namespace path: skip
namespaces the caller cannot read (401/403) and aggregate the rest, so a
partially-authorized caller still sees what they can read; other errors
propagate. If the caller can read no namespace, the namespace enumeration
itself raises the normal unauthorized error.
@circy9 Liqian Luo (circy9) changed the title {aimanager} Shorten modeldeployment args and add list --all-namespaces {aimanager} Shorten modeldeployment args and list across namespaces Sep 16, 2026
Per PR review, add tests for the authorization edge cases of listing
model deployments across namespaces:
- namespace enumeration itself unauthorized -> error propagates
- deployments unauthorized in every namespace -> surface the unauthorized
  error instead of returning an empty list

Adjust list_modeldeployment to track whether any namespace was readable
and re-raise the last auth error when none were, matching the reviewer's
"authorized for 0 namespaces shows the normal unauthorized message" rule.

@circy9 Liqian Luo (circy9) left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

  1. Did you update command help instructions to clearly state that the user must have namespace read permissions upon the specified AI manager resource if --namespace or --ns is unspecified?

  2. When --namespace is omitted, if the user is unauthorized to list modeldeployments for a subset of namespaces and we skip those namespaces, did you make sure the cli outputs a warning message for each skipped namespace?

  3. When --namespace is omitted, if the user is unauthorized to list namespaces, did you make sure the error message shown to the user clearly state that the user must have namespace read permissions upon the specified AI manager resource. If not, the user can use --namespace or --ns to list modeldeployments for one specific namespace.

Address review feedback on listing model deployments without --namespace:

- Document in the command help (long-summary) that omitting --namespace
  requires namespace read permission on the AI Manager, that
  unauthorized namespaces are skipped with a warning, and that
  --namespace/--ns lists a single namespace instead.
- Emit a clear per-namespace warning naming each skipped, unauthorized
  namespace.
- When the caller cannot enumerate namespaces, or can read none of them,
  raise an actionable UnauthorizedError that states the required
  permission and suggests --namespace/--ns for a single namespace.
@circy9

Copy link
Copy Markdown
Contributor Author

Addressed all three points in 6643000d:

1. Help text — permission requirement when --namespace is omitted. Added a long-summary to aimanager namespace modeldeployment list:

If --namespace/--ns is omitted, model deployments are listed across all readable namespaces of the AI Manager; this requires permission to read namespaces on the specified AI Manager resource. Namespaces you are not authorized to read are skipped with a warning. If you cannot read namespaces at all, specify --namespace/--ns to list model deployments for one specific namespace.

2. Per-namespace warning for skipped namespaces. Each unauthorized namespace now logs its own warning naming the namespace:

WARNING: Skipping namespace 'ns1': not authorized to list its model deployments.

Covered by unit test test_list_without_namespace_skips_forbidden_namespaces (asserts a warning mentioning the skipped namespace).

3. Actionable error when namespaces can't be listed (or none are readable). When the caller can't enumerate namespaces — or can enumerate but is denied in every one — the command now raises an UnauthorizedError whose recommendation states the required permission and points to the single-namespace form:

Listing model deployments without --namespace/--ns requires permission to read namespaces on AI Manager ''. If you cannot read namespaces, specify --namespace/--ns to list model deployments for one specific namespace.

Covered by test_list_without_namespace_propagates_namespace_list_unauthorized and test_list_without_namespace_all_forbidden_raises.

Validation: azdev test azext_aimanager --discover --series → 81 passed; azdev style / azdev linter clean; live-verified the cross-namespace and scoped paths.

Correct the permission model in help and error messages. Listing model
deployments without --namespace involves two distinct permissions:

1. Listing namespaces (list_by_ai_manager) requires namespace read on
   the AI Manager resource; without it no namespaces can be listed.
2. Listing deployments per namespace (list_by_ai_manager_namespace)
   requires model deployment read on each namespace resource, which the
   caller may hold for some namespaces but not others.

The earlier messaging conflated the two. Now the namespace-enumeration
failure names the AI-Manager namespace-read requirement, while the
all-namespaces-forbidden case names the per-namespace model-deployment-
read requirement. Update help long-summary and tests accordingly.
@circy9

Copy link
Copy Markdown
Contributor Author

You're right — my previous change conflated the two permission layers. Corrected in 3ef607f3:

Two distinct permissions when --namespace is omitted:

  1. List namespaces (list_by_ai_manager) — requires namespace read on the AI Manager resource. Without it, no namespaces can be listed at all.
  2. List deployments per namespace (list_by_ai_manager_namespace) — requires model deployment read on each namespace resource. The caller may hold this for some namespaces but not others.

Behavior now:

  • Can't list namespaces (layer 1 denied) → UnauthorizedError: "...first lists namespaces, which requires namespace read permission on AI Manager ''. Grant that permission, or specify --namespace/--ns to list model deployments for a single namespace."
  • Namespaces listed, but denied model-deployment-read on some → those namespaces are skipped with a per-namespace warning (Skipping namespace 'ns1': not authorized to read its model deployments.), and the readable ones are returned.
  • Denied on every namespace (layer 2 denied everywhere) → UnauthorizedError: "Not authorized to read model deployments in any namespace of AI Manager ''. Model deployment read permission is granted per namespace; ask for access to a namespace, then use --namespace/--ns to list it."

Help long-summary and unit tests updated to assert the two distinct messages. azdev test --discover --series → 81 passed; style + linter clean.

Address review feedback:
- When the caller can list namespaces but lacks model deployment read on
  every one, do not suggest --namespace/--ns: scoping to a single
  namespace would fail too. The error now asks for model deployment read
  access on a namespace instead.
- Remove a duplicated return statement in list_modeldeployment.
- Tests now assert the full warning and error-recommendation text
  instead of substrings.
Per review, model deployment read is not "granted per namespace" only:
it can be granted on the namespace resource, or inherited from the parent
AI Manager resource (covering all its namespaces). Reword the
all-forbidden error, the command help long-summary, and HISTORY to
reflect both grant scopes.
@circy9

Copy link
Copy Markdown
Contributor Author

Live CLI test results (real invocations)

Ran against a live preview subscription with the dev extension active (branch HEAD b1cd7412). Resource group aimtest-0915, AI Manager aimbase0915, namespaces ns1 (md1) and ns2 (md2).

Argument renames

# Command Result
1 ... namespace list --aimanager aimbase0915 ✅ lists ns1, ns2
2 ... namespace list -m aimbase0915 (alias) ✅ same output
3 ... namespace list --aimanager-name aimbase0915 (old) ✅ rejected: --aimanager/--manager/-m required
4 ... modeldeployment list --aimanager … --namespace ns2 ✅ scoped to ns2/md2
5 ... modeldeployment list … --ns ns1 (alias) ✅ scoped to ns1/md1
6 ... modeldeployment list … --namespace-name ns1 (old) ✅ rejected: unrecognized arguments: --namespace-name

Cross-namespace list (omit --namespace)

7. az aimanager namespace modeldeployment list -g aimtest-0915 --aimanager aimbase0915 -o table

Namespace    Name    ProvisioningState    Replicas    Age     ModelId                Endpoint
-----------  ------  -------------------  ----------  ------  ---------------------  ------------------------------
ns1          md1     Succeeded            1/1         21h45m  google/gemma-4-E4B-it  https://ns1.<...>.aksapp.io/v1
ns2          md2     Succeeded            0/1         16h38m  google/gemma-4-E4B-it  https://ns2.<...>.aksapp.io/v1

8. --query "length(@)" -o tsv → 2 (both namespaces aggregated).

Help

9. --help shows the permission long-summary (namespace read on the AI Manager to list namespaces; model deployment read per namespace, granted on the namespace or inherited from the AI Manager) and --namespace --ns as optional with the "lists across all readable namespaces if omitted" description.

All live invocations behave as expected.

@circy9
Liqian Luo (circy9) merged commit 433c831 into Azure:main Sep 16, 2026
24 checks passed
@azclibot

Copy link
Copy Markdown
Collaborator

[Release] Update index.json for extension [ aimanager-1.5.4b1 ] : https://dev.azure.com/msazure/One/_build/results?buildId=181409875&view=results

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

Labels

AKS Auto-Assign Auto assign by bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants