Repository navigation
[Containerapp] az containerapp up: Validate image registry before inferring credentials - #34302
Conversation
…erring credentials Use the image authority and supported ACR hostname helpers for registry inference. Derive the lookup name from that validated authority and retain explicit credentials and existing lookup error handling. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Automatic registry credential lookup does not enforce cloud matching, risking exposure of admin credentials to an unrelated registry and causing authentication failures.
3 open issues
What changed in this PR
This PR tightens registry credential inference for az containerapp up --image, complementing #34262’s registry-server validation.
Changes:
- Uses the image’s registry authority and shared ACR suffix helpers instead of substring matching.
- Adds registry-name validation before credential lookup.
- Adds mocked tests for malformed authorities, sovereign-cloud suffixes, credentials, lookup failures, and the defaults path.
| File | Description |
|---|---|
src/azure-cli/azure/cli/command_modules/containerapp/tests/latest/test_containerapp_up_image_unit.py |
Adds unit coverage for image-based registry inference. |
src/azure-cli/azure/cli/command_modules/containerapp/_up_utils.py |
Validates the registry authority before inferring ACR credentials. |
Review effort: Balanced
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Recognize registry.region.geo authorities before validating the ACR resource name, preserving the complete registry destination. Cover regional tag and digest references, partial credentials, supported cloud suffixes, defaults inference, and malformed or non-ASCII authorities. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Chris Ross (Tratcher)
left a comment
There was a problem hiding this comment.
Duplicate of #34262?
Thanks for checking. These are related, but they cover different credential-inference paths. [Azure/azure-cli#34262](#34262) adds validation in azure-cli/src/azure-cli/azure/cli/command_modules/containerapp/custom.py Lines 3714 to 3728 in 193d163 _get_registry_details() is not called—it is only invoked when source or repo is supplied—so the validation in the other PR does not cover this entry point.
The intent is to complement [Azure/azure-cli#34262](#34262). The added tests exercise the image-inference path, including the defaults call path and valid regional ACR endpoints. |


🤖 PR Validation — ️✔️ All clear
Related command
az containerapp up --imageDescription
Use the existing ACR hostname helpers for image-based registry inference in
az containerapp up.<registry>.<region>.georegional endpoints, using the resource name for credential lookup while preserving the complete registry authority.This complements #34262 by updating the image-inference entry point, rather than duplicating its registry-details validation. The change is independently applicable to
dev.Testing Guide
From the Azure CLI repository root, using the existing Azure CLI 2.91.0 Python runtime for dependencies:
Result: passed, 7 test methods and their parameterized subtests for commit
193d16323b2c6c4f78436ef895ca372907b686ef. Before the regional-endpoint correction, the expanded suite failed with 31 failing cases. Tests load the checked-out command module; resource and credential operations are mocked.Result: passed before committing.
Full repository
azdev/CI suites and live Azure scenarios were not run locally for this revision. The bot-managed validation section above tracks CI separately.History Notes
[Containerapp]
az containerapp up: Validate image registry before inferring credentialsThis checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.