Skip to content

Changes to az commands to support managed identity in Connected Registry [DRAFT] - #33910

Open
Dhawal Jain (dhawal777) wants to merge 3 commits into
Azure:devfrom
dhawal777:dhja_acr-connected-registry-managed-identity
Open

Changes to az commands to support managed identity in Connected Registry [DRAFT]#33910
Dhawal Jain (dhawal777) wants to merge 3 commits into
Azure:devfrom
dhawal777:dhja_acr-connected-registry-managed-identity

Conversation

@dhawal777

Copy link
Copy Markdown

Related command

Description

Testing Guide

History Notes

[Component Name 1] BREAKING CHANGE: az command a: Make some customer-facing breaking change
[Component Name 2] az command b: Add some customer-facing feature


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

Dhawal Jain and others added 2 commits August 13, 2026 17:04
Add user-assigned managed identity as an authentication mode between a
connected registry and its parent, alongside existing sync-token auth.

New / changed CLI surface
-------------------------
* `az acr connected-registry create`
  * `--auth-type {SyncToken, ManagedIdentity}` (default: `SyncToken`).
  * `--identity <user-assigned identity resource id>` (required when
    `--auth-type ManagedIdentity`).
  * `--sync-token` and `--repository` are rejected in `ManagedIdentity`
    mode.
* `az acr connected-registry update`
  * Supports migrating an existing connected registry between
    `SyncToken` and `ManagedIdentity` auth modes.
  * Registry must be in `Offline` state; same-mode credential rotation
    is not supported.
  * Migration MI -> SyncToken deliberately omits `identity` from the
    PATCH payload to avoid ARM `ConflictingAuthInput`.
* `az acr connected-registry get-settings`
  * When the target is `ManagedIdentity`-mode, emits a MI-flavored
    connection string with `ACR_MANAGED_IDENTITY_CLIENT_ID` and
    `ACR_MANAGED_IDENTITY_RESOURCE_ID` and skips sync-token password
    generation.
* `az acr connected-registry permissions {show, update}`
  * Reject with a clear error against `ManagedIdentity`-mode registries
    (sync-token scope map is not applicable in that mode).

Implementation notes
--------------------
* Direct imports of `AuthType`, `ConnectionState`, `ManagedServiceIdentity`,
  `ManagedServiceIdentityType`, `UserAssignedIdentity` etc. from the flat
  `azure.mgmt.containerregistry.models` namespace; SDK enums are coerced
  via `.value` because they are not `StrEnum`.
* `_get_current_auth_type` is defensive against both raw-string and enum
  server responses (bug guard).
* Delete skips sync-token / scope-map cleanup for MI-mode registries
  (bug guard).

Tests
-----
* Unit tests: `test_acr_connected_registry_mi_unit.py` (31 tests) cover
  create/update validation, migration state machine (both directions,
  including MI -> SyncToken identity-omission regression guard), delete
  MI-mode cleanup guard, `get-settings` MI branch, and permissions
  MI-mode rejection.
* Scenario test: `test_acr_connectedregistry_managed_identity` added
  (currently `@record_only()`; cassette pending because the SDK preview
  API is not yet available on the public control plane).

Dependencies
------------
* Bump `azure-mgmt-containerregistry` to `15.1.0b3` for the preview
  api-version that exposes the connected-registry MI contract.
Copilot AI lite review requested due to automatic review settings August 17, 2026 19:05
@azure-client-tools-bot-prd

Copy link
Copy Markdown

Hi Dhawal Jain (@dhawal777),
Since the current milestone time is less than 7 days, this pr may not catch up with this release.

@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

This PR updates the ACR connected-registry command set to support Managed Identity (user-assigned) authentication in addition to the existing SyncToken flow, including migration between the two modes.

Changes:

  • Adds --auth-type (SyncToken | ManagedIdentity) and --identity to az acr connected-registry create/update, plus migration validation logic.
  • Updates get-settings output and blocks permissions operations for ManagedIdentity-mode registries.
  • Bumps azure-mgmt-containerregistry to 15.1.0b3 and adds scenario + unit test coverage for MI paths.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/azure-cli/setup.py Bumps azure-mgmt-containerregistry dependency to 15.1.0b3.
src/azure-cli/HISTORY.rst Adds upcoming release notes for MI support and SDK bump.
src/azure-cli/azure/cli/command_modules/acr/connected_registry.py Implements MI auth support, migration validation, MI-aware delete/get-settings/permissions behavior.
src/azure-cli/azure/cli/command_modules/acr/_params.py Introduces CLI parameters --auth-type, --identity, and update-only --sync-token for migration.
src/azure-cli/azure/cli/command_modules/acr/_help.py Documents MI create and migration examples; updates permissions group description.
src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_connectedregistry_commands.py Adds a recorded scenario test covering MI create/show/get-settings/delete.
src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_connected_registry_mi_unit.py Adds unit tests for MI mode validation, PATCH shape, MI-mode delete behavior, and MI get-settings output.

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

Comment on lines +271 to +277
current_state = getattr(current_connected_registry, 'connection_state', None)
if current_state != CONNECTION_STATE_OFFLINE:
raise ArgumentUsageError(
"argument error: connected registry must be in '{}' state to migrate authentication mode. "
"Current state is '{}'. Deactivate it first with "
"'az acr connected-registry deactivate'.".format(CONNECTION_STATE_OFFLINE, current_state)
)
helps['acr connected-registry permissions'] = """
type: group
short-summary: Manage the repository permissions accross multiple connected registries. Please see https://aka.ms/acr/connected-registry for more information.
short-summary: Manage the repository permissions accross multiple connected registries. Only supported for connected registries configured with SyncToken authentication (output is derived from the sync-token scope map). Please see https://aka.ms/acr/connected-registry for more information.
@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

@dhawal777 Dhawal Jain (dhawal777) changed the title Changes to az commands to support managed identity in Connected Registry Changes to az commands to support managed identity in Connected Registry [DRAFT] Aug 18, 2026
@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

@a0x1ab Aditya Pujara (a0x1ab) added the Azure Client Tools Agent Requested Request Azure Client Tools Agent testing and review label Aug 19, 2026
@azure-client-tools-agent

Copy link
Copy Markdown
Contributor

Live test results — azdev test --live --series (changed test files only)

⚠️ NO TESTS SELECTED — changed test files did not resolve to runnable tests

Selectors: test_acr_connected_registry_mi_unit test_acr_connectedregistry_commands (module)
PR head ref: dhja_acr-connected-registry-managed-identity
PR head sha: aa111523db33a8c37c7a9b10a9b22ad6ed30015a
PR base ref: dev
New test files in PR: true

Changed test files run
src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_connected_registry_mi_unit.py
src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_connectedregistry_commands.py

New test files
src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_connected_registry_mi_unit.py

Workflow run: https://github.com/Azure/issue-sentinel/actions/runs/32217890823

Last 80 lines of azdev output

=============
| Run Tests |
=============


=====================
| Discovering Tests |
=====================

/home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py:13640: SyntaxWarning: invalid escape sequence '\]'
  self.cmd('vmss application set -g {rg} -n {vmss} --app-version-ids {vid1} {vid2} --enable-automatic-upgrade True\]', checks=[
ERROR: 'NoneType' object has no attribute '__dict__'
Traceback (most recent call last):
  File "/home/runner/work/issue-sentinel/issue-sentinel/.venv/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/issue-sentinel/issue-sentinel/.venv/lib/python3.12/site-packages/knack/invocation.py", line 224, in execute
    cmd_result = parsed_args.func(params)
                 ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/issue-sentinel/issue-sentinel/.venv/lib/python3.12/site-packages/knack/commands.py", line 149, in __call__
    return self.handler(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/issue-sentinel/issue-sentinel/.venv/lib/python3.12/site-packages/knack/commands.py", line 256, in _command_handler
    result = op(client, **command_args) if client else op(**command_args)
                                                       ^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/issue-sentinel/issue-sentinel/.venv/lib/python3.12/site-packages/azdev/operations/testtool/__init__.py", line 58, in run_tests
    test_index = _get_test_index(profile or current_profile(), discover, target_tests=target_tests)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/issue-sentinel/issue-sentinel/.venv/lib/python3.12/site-packages/azdev/operations/testtool/__init__.py", line 327, in _get_test_index
    test_index = _discover_tests(profile, target_tests)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/issue-sentinel/issue-sentinel/.venv/lib/python3.12/site-packages/azdev/operations/testtool/__init__.py", line 243, in _discover_tests
    tests = _discover_module_tests(mod_name, mod_data)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/issue-sentinel/issue-sentinel/.venv/lib/python3.12/site-packages/azdev/operations/testtool/__init__.py", line 177, in _discover_module_tests
    module = import_module(test_file_path)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 999, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_custom_vm_commands.py", line 33, in <module>
    CachingTypes = get_sdk(DummyCli(), ResourceType.MGMT_COMPUTE, 'NetworkProfile', 'StorageProfile', 'DataDisk', 'OSDisk',
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli-core/azure/cli/core/profiles/__init__.py", line 91, in get_sdk
    return _sdk_get_versioned_sdk(cli_ctx.cloud.profile, resource_type, *attr_args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli-core/azure/cli/core/profiles/_shared.py", line 474, in get_versioned_sdk
    sdk_path = get_versioned_sdk_path(api_profile, resource_type, operation_group)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli-core/azure/cli/core/profiles/_shared.py", line 466, in get_versioned_sdk_path
    api_version = getattr(api_version, operation_group)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli-core/azure/cli/core/profiles/_shared.py", line 261, in __getattr__
    self._resolve()
  File "/home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli-core/azure/cli/core/profiles/_shared.py", line 248, in _resolve
    for operation_group_name, operation_type in self._client_type.__dict__.items():
                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute '__dict__'. Did you mean: '__dir__'?

Posted by agent-assist live-test workflow.

@azure-client-tools-agent azure-client-tools-agent Bot added the azure-client-tools-agent Pull request reviewed by Azure Client Tools Agent label Aug 19, 2026

@azure-client-tools-agent azure-client-tools-agent Bot 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.

The following CI checks are failing:

  • azdev-linter
  • azdev-style
  • Azure.azure-cli
  • Azure.azure-cli (Integration Test against Profiles Python314)
  • Azure.azure-cli (Integration Test against Profiles Python312)
  • Azure.azure-cli (Test Python Wheels Python314)
  • Azure.azure-cli (Test Python Wheels Python312)
  • Azure.azure-cli (Test Extensions Loading Python314)
  • Azure.azure-cli (Build Windows MSI x86)
  • Azure.azure-cli (Build Windows MSI x64)
  • Azure.azure-cli (Build Windows ZIP x64)
  • Azure.azure-cli Full Test
  • Azure.azure-cli Full Test (Automation Full Test Python314 Profile Latest instance7)
  • Azure.azure-cli Full Test (Automation Full Test Python314 Profile Latest instance8)
  • Azure.azure-cli Full Test (Automation Full Test Python314 Profile Latest instance2)
  • Azure.azure-cli Full Test (Automation Full Test Python314 Profile Latest instance5)
  • Azure.azure-cli Full Test (Automation Full Test Python314 Profile Latest instance6)
  • Azure.azure-cli Full Test (Automation Full Test Python314 Profile Latest instance1)
  • Azure.azure-cli Full Test (Automation Full Test Python314 Profile Latest instance4)
  • Azure.azure-cli Full Test (Automation Full Test Python312 Profile Latest instance7)
  • Azure.azure-cli Full Test (Automation Full Test Python314 Profile Latest instance3)
  • Azure.azure-cli Full Test (Automation Full Test Python312 Profile Latest instance6)
  • Azure.azure-cli Breaking Change Test
  • Azure.azure-cli (PerformanceCheck Python312)
  • Azure.azure-cli (Secret Scan)
  • Azure.azure-cli Full Test (Automation Full Test Python312 Profile Latest instance1)
  • Azure.azure-cli Full Test (Automation Full Test Python312 Profile Latest instance2)
  • Azure.azure-cli Full Test (Automation Full Test Python312 Profile Latest instance5)
  • Azure.azure-cli Full Test (Automation Full Test Python312 Profile Latest instance8)
  • Azure.azure-cli Full Test (Automation Full Test Python312 Profile Latest instance3)
  • Azure.azure-cli (Unit Test for Telemetry Python312)
  • Azure.azure-cli (Unit Test for Telemetry Python314)
  • Azure.azure-cli Full Test (Automation Full Test Python312 Profile Latest instance4)
  • Azure.azure-cli (Check License, History, and DocMap)
  • Azure.azure-cli (Check the Format of Pull Request Title and Content)
  • Azure.azure-cli (PerformanceCheck Python314)
  • Azure.azure-cli (Verify latest index assets)
  • Azure.azure-cli (Unit Test for Core Python312)
  • Azure.azure-cli (Check CLI Linter)
  • Azure.azure-cli (Verify src/azure-cli/requirements.*.Linux.txt)
  • Azure.azure-cli (Unit Test for Core Python314)
  • Azure.azure-cli (Check CLI Style)
  • Azure.azure-cli (Verify src/azure-cli/requirements.*.Windows.txt)
  • Azure.azure-cli (Verify src/azure-cli/requirements.*.Darwin.txt)
  • azdev-style
  • azdev-linter
  • Live test run failed (see the dispatched live-test.yml workflow run for details).

@azure-client-tools-agent azure-client-tools-agent Bot removed the Azure Client Tools Agent Requested Request Azure Client Tools Agent testing and review label Aug 19, 2026
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 reviewed by Azure Client Tools Agent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants