Skip to content

[ACR] az acr import: Add cross-tenant import support - #34210

Open
Bin Du (northtyphoon) wants to merge 3 commits into
Azure:devfrom
northtyphoon:acr-import-cross-tenant
Open

Bin Du (northtyphoon) wants to merge 3 commits into
Azure:devfrom
northtyphoon:acr-import-cross-tenant

Conversation

@northtyphoon

Copy link
Copy Markdown
Member

Related command

az acr import

Description

Add --registry-tenant to support importing images from an Azure Container Registry in another tenant.

When specified, Azure CLI uses the current identity to acquire an auxiliary ARM token for the source registry tenant and includes it on the import management API request. The option is accepted only when --registry is a Container Registry resource ID; registry names, login servers, missing registry values, and non-ACR resource IDs are rejected.

This change also adds command help and a cross-tenant example.

Testing Guide

python -m unittest azure.cli.command_modules.acr.tests.latest.test_acr_client_factory
az acr import --help

Confirm that help includes --registry-tenant, and that using it with a registry name fails before an import request is sent.


Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 10, 2026 00:02
@northtyphoon
Bin Du (northtyphoon) requested a review from a team as a code owner October 10, 2026 00:02
@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.

🟡 Changes recommended

Managed-identity and Cloud Shell logins silently omit the auxiliary token, causing advertised cross-tenant imports to fail.

1 open finding
What changed in this PR

Adds cross-tenant ACR image imports using auxiliary ARM authentication.

Changes:

  • Adds --registry-tenant with validation and help.
  • Uses an auxiliary tenant when creating the import client.
  • Adds focused client-factory tests.
File Description
_client_factory.py Validates source registry IDs and configures auxiliary authentication.
commands.py Registers the import-specific client factory.
_params.py Defines --registry-tenant.
_help.py Adds a cross-tenant example.
test_acr_client_factory.py Tests validation and tenant forwarding.

🧠 Review effort: Balanced


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

raise ArgumentUsageError(REGISTRY_TENANT_USAGE_ERROR)

aux_tenants = [registry_tenant] if registry_tenant else None
return get_acr_service_client(cli_ctx, aux_tenants=aux_tenants).registries

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Addressed in 4136ed7. --registry-tenant now rejects managed identity and Cloud Shell login modes before client creation, with focused unit coverage.

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

@yonzhan

Copy link
Copy Markdown
Collaborator

Please fix CI issues

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@northtyphoon

Copy link
Copy Markdown
Member Author

Pushed 4136ed7 to address the review and linter failures: exposed registry_tenant in the command handler signature, added scenario coverage for --registry-tenant, and rejected managed identity/Cloud Shell authentication before sending the import request.

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@northtyphoon

Copy link
Copy Markdown
Member Author

Fixed the pylint failure in 1f54ef5. registry_tenant intentionally remains in the handler signature so the CLI parser exposes --registry-tenant; its value is consumed by the import client factory, so the handler parameter now uses the standard inline unused-argument suppression.

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

@Zefty Jaime Wu (Zefty) left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

@cegraybl Cesar Gray (cegraybl) 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.

LGTM

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.

7 participants