Skip to content

[ACR] az acr connected-registry: Add support for managed identity options - #34106

Open
nihalvar wants to merge 16 commits into
Azure:devfrom
nihalvar:acr-connected-registry-managed-identity
Open

nihalvar wants to merge 16 commits into
Azure:devfrom
nihalvar:acr-connected-registry-managed-identity

Conversation

@nihalvar

@nihalvar nihalvar commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

🤖 PR Validation — ⚠️ Review suggested

Breaking Changes Tests
⚠️ None ️✔️ 130/130
⚠️AzureCLI-BreakingChangeTest
⚠️acr
rule cmd_name rule_message suggest_message
⚠️ 1006 - ParaAdd acr connected-registry create cmd acr connected-registry create added parameter auth_type
⚠️ 1006 - ParaAdd acr connected-registry create cmd acr connected-registry create added parameter identity
⚠️ 1006 - ParaAdd acr connected-registry update cmd acr connected-registry update added parameter auth_type
⚠️ 1006 - ParaAdd acr connected-registry update cmd acr connected-registry update added parameter identity

Related command

az acr connected-registry create, update, get-settings, delete, and permissions show/update.

Description

Adds user-assigned managed identity authentication as an alternative to sync tokens for connected registries.

Referenced PR: #33910

  • Adds --auth-type and --identity to create connected registries using an existing user-assigned identity, without creating sync tokens or scope maps.
  • Supports one-way SyncToken → ManagedIdentity migration through update. The service validates migration eligibility, including the required Offline state. Unrelated connected-registry settings are preserved.
  • Returns the identity’s client ID in ACR_REGISTRY_CONNECTION_STRING, without sync-token credentials. Password generation and sync-token permission operations are rejected for MI registries.
  • Makes deletion authentication-aware: MI registries skip sync-token and scope-map cleanup, with or without --cleanup. Separately owned identities and role assignments are not deleted.
  • Preserves existing SyncToken behavior, including legacy resources that omit authType, and updates argument help and examples.
    The CLI does not automatically create the managed identity or assign its roles. No intentional breaking changes.

Testing Guide

Adds unit coverage in test_acr_connected_registry_mi_unit.py for validation, identity payloads, migration updates, service-error propagation, connection settings, and deletion with both cleanup values. Existing SyncToken settings and cleanup behavior have regression coverage.

Two recorded scenarios are included:

Scenario Coverage
test_acr_connectedregistry_managed_identity Create, show, verify the expected client ID in connection settings, and delete without --cleanup.
test_acr_connectedregistry_managed_identity_migration Create an Offline/Inactive SyncToken registry, migrate to MI, and read it back. Verify the attached identity, client ID, and preservation of unrelated settings. Delete with --cleanup and confirm the identity still exists.

Both scenarios use Premium, ABAC-enabled registries with dedicated data endpoints. Their recordings are included in tests/latest/recordings.

These scenarios cover control-plane behavior without deploying an agent. The migration starts with a newly created Offline/Inactive registry; no Online-to-Offline transition is required. Runtime MI authentication and image synchronization are outside this coverage.

az acr connected-registry create
create mi cli

az acr connected-registry update
cli mi update

az acr connected-registry get-settings
get settings mi cli

az acr connected-registry delete
mi cleanup cli

History Notes

[ACR] az acr connected-registry create: Add user-assigned managed identity authentication options
[ACR] az acr connected-registry update: Add one-way migration from SyncToken to managed identity authentication
[ACR] az acr connected-registry get-settings: Return managed identity connection settings
[ACR] az acr connected-registry delete: Skip sync-token cleanup for managed identity authentication


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

Nihal Varadachari added 5 commits September 16, 2026 15:42
Transplant the authentication discriminator, ManagedIdentity target guards, SyncToken-only help, and focused source unit tests.

Source PR: Azure#33910
Source SHA: e0b7694
Transplant CREATE options, inline authentication branches, identity shaping, request payload, example, and source validation tests. Retain cmd.get_models and legacy SyncToken validation.

Require a nonblank identity and reject explicitly supplied incompatible options. Enforce top-level MI and immediate-parent leaf guards before mutations; defer data-endpoint enablement until parent validation. Cover the guards and real SDK payload/token paths.

Source PR: Azure#33910
Source SHA: e0b7694
Reuse the UPDATE arguments, inline input handling and PATCH shaping from Azure#33910, source e0b7694, with the existing SDK model helper.

Keep ManagedIdentity as the only migration target. Require explicit auth type and a nonblank identity, while deferring current-auth and Offline eligibility checks to the RP.

Correct the migration example and cover empty inputs, RP-error propagation, migration combined with ordinary property changes, and preservation of auth during ordinary updates.
Transfer GET-SETTINGS helpers, ManagedIdentity early return, and the shared
SyncToken settings tail from the pinned original implementation.

Source: Azure#33910
Source-commit: e0b7694

Preserve source response guards, request-name selection, endpoint/protocol
resolution, output keys, errors, and MI --generate-password rejection.
Keep accepted CREATE, permissions, UPDATE, fixtures, and tests unchanged.

Deviations/integration:
- Add a handler-level too-many-locals pylint annotation (26 vs limit 25)
  rather than restructuring the original source.
- Reuse existing test fixtures/imports; copy the four MI tests and helper,
  adding one exact-output/no-token-or-credential-call test and one six-case
  SyncToken regression test. Update the test module description/import.
- Clarify optional SyncToken generation and MI rejection in get-settings
  help/argument help, plus the deprecated renew-credentials restriction.
  Preserve examples and all parameter defaults/requirements.

The source connection-string format is not independently verified against
inaccessible specification section 3.3. Request-name vs GET-response-name
and endpoint contract questions remain separately reported, not fixed.

Validation: 34 mock-only unit tests pass; six SyncToken cases also pass
against the accepted pre-transfer handler. Scoped flake8/pylint, help and
command/parameter lint, in-memory compilation, and source-fidelity checks
pass. No live Azure or recording validation performed.
@azure-client-tools-bot-prd

Copy link
Copy Markdown

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

@yonzhan

Copy link
Copy Markdown
Collaborator

ACR

@nihalvar nihalvar changed the title [ACR] az acr connected-registry: add support for managed identity options [ACR] az acr connected-registry: Add support for managed identity options Sep 21, 2026
@nihalvar
nihalvar marked this pull request as ready for review September 21, 2026 05:46
@nihalvar
nihalvar requested a review from a team as a code owner September 21, 2026 05:46
Copilot AI lite review requested due to automatic review settings September 21, 2026 05:46

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.

Copilot review overview

🟡 Changes recommended

A unit test has deterministic failing assertions, and the migration help text needs correction.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity · 1 Low severity

Open (2)
What changed in this PR

Adds user-assigned managed identity support for ACR connected registries, including creation, migration, settings, and cleanup behavior.

Changes:

  • Adds --auth-type and --identity options.
  • Supports SyncToken-to-managed-identity migration.
  • Updates MI-aware settings, permissions, deletion, and documentation.
  • Adds unit, scenario, and recording coverage.
File Description
src/​azure-cli/​azure/​cli/​command_modules/​acr/​tests/​latest/​test_acr_connectedregistry_commands.py Adds managed identity scenario coverage.
src/​azure-cli/​azure/​cli/​command_modules/​acr/​tests/​latest/​test_acr_connected_registry_mi_unit.py Adds MI-focused unit tests; contains assertions that incorrectly reject required lookups.
src/​azure-cli/​azure/​cli/​command_modules/​acr/​tests/​latest/​recordings/​test_acr_connectedregistry_managed_identity.yaml Records managed identity scenario interactions.
src/​azure-cli/​azure/​cli/​command_modules/​acr/​connected_registry.py Implements managed identity workflows.
src/​azure-cli/​azure/​cli/​command_modules/​acr/​_params.py Adds managed identity CLI arguments.
src/​azure-cli/​azure/​cli/​command_modules/​acr/​_help.py Documents MI workflows; deactivation guidance should account for Offline/Inactive registries.
src/​azure-cli/​azure/​cli/​command_modules/​acr/​_constants.py Defines authentication types.

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

Comment thread src/azure-cli/azure/cli/command_modules/acr/_help.py Outdated
Clarify migration prerequisites for connected registry.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment thread src/azure-cli/azure/cli/command_modules/acr/connected_registry.py Outdated
Comment thread src/azure-cli/azure/cli/command_modules/acr/connected_registry.py
Comment thread src/azure-cli/azure/cli/command_modules/acr/connected_registry.py
Comment thread src/azure-cli/azure/cli/command_modules/acr/_params.py Outdated
Comment thread src/azure-cli/azure/cli/command_modules/acr/_params.py Outdated
Comment thread src/azure-cli/azure/cli/command_modules/acr/_params.py Outdated

@lizMSFT Zoey Li (lizMSFT) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Left a few nit comments

Comment thread src/azure-cli/azure/cli/command_modules/acr/connected_registry.py Outdated
Comment thread src/azure-cli/azure/cli/command_modules/acr/connected_registry.py Outdated
Comment thread src/azure-cli/azure/cli/command_modules/acr/connected_registry.py Outdated

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants