Add --image and --entrypoint params to containerapp debug command#9868
Add --image and --entrypoint params to containerapp debug command#9868khkh-ms wants to merge 4 commits into
Conversation
|
Hi @khkh-ms, |
|
Validation for Breaking Change Starting...
Thanks for your contribution! |
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
|
The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR. Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions). pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>
|
|
There was a problem hiding this comment.
Pull request overview
This PR aims to extend az containerapp debug so users can customize the debug ephemeral container by specifying a container image (--image) and an entrypoint (--entrypoint). This is implemented by adding new CLI arguments and (when provided) appending corresponding query parameters to the debug endpoint URL.
Changes:
- Added
--imageand--entrypointoptional parameters tocontainerapp debug. - Updated debug URL construction to include
customDebugImageNameandcustomDebugImageEntrypointCommandquery params when set. - Added client-side validation that
--entrypointrequires--image, plus new help examples.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/containerapp/azext_containerapp/containerapp_debug_command_decorator.py | Adds new argument accessors, appends custom image/entrypoint query params, and introduces entrypoint/image validation. |
| src/containerapp/azext_containerapp/_params.py | Registers the new --image / --entrypoint CLI arguments for containerapp debug. |
| src/containerapp/azext_containerapp/_help.py | Adds usage examples demonstrating --image and --entrypoint. |
Comments suppressed due to low confidence (1)
src/containerapp/azext_containerapp/containerapp_debug_command_decorator.py:99
- Validation for
--entrypointrequiring--imageis implemented insideexecute_Command, but this method is only used for the non-interactive--commandflow. Once the new args are wired through, the interactive debug console path (WebSocket) would bypass this check. Consider moving this validation intovalidate_argumentsand/or the command validator (validate_debug) so it applies consistently for both interactive and non-interactive debug.
custom_debug_image_name = self.get_argument_custom_debug_image_name()
custom_debug_image_entrypoint_command = self.get_argument_custom_debug_image_entrypoint_command()
if custom_debug_image_entrypoint_command and not custom_debug_image_name:
raise ValidationError("--entrypoint requires --image to also be specified.")
url = self._get_url(cmd, resource_group_name, container_app_name, revision_name, replica_name, container_name, command, custom_debug_image_name, custom_debug_image_entrypoint_command)
| c.argument('custom_debug_image_name', options_list=['--image'], | ||
| help="Custom container image for the debug ephemeral container (e.g., 'mcr.microsoft.com/dotnet/sdk:8.0'). If not specified, the platform default debug image is used.") | ||
| c.argument('custom_debug_image_entrypoint_command', options_list=['--entrypoint'], | ||
| help="Custom entrypoint command for the debug container (e.g., '/bin/bash'). Requires --image to also be specified.") |
There was a problem hiding this comment.
Addressed in commit acf432b: containerapp_debug(...) in custom.py now accepts custom_debug_image_name and custom_debug_image_entrypoint_command and forwards them via raw_parameters into ContainerAppDebugCommandDecorator. Verified end-to-end (WebSocket request URL contains both encoded params; server returns HTTP 101).
There was a problem hiding this comment.
Addressed in commit acf432b: containerapp_debug(...) in custom.py now accepts custom_debug_image_name and custom_debug_image_entrypoint_command and forwards them via raw_parameters into ContainerAppDebugCommandDecorator. Verified end-to-end (WebSocket request URL contains both encoded params; server returns HTTP 101).
| if custom_debug_image_name: | ||
| debug_url += f"&customDebugImageName={urllib.parse.quote_plus(custom_debug_image_name)}" | ||
| if custom_debug_image_entrypoint_command: | ||
| debug_url += f"&customDebugImageEntrypointCommand={urllib.parse.quote_plus(custom_debug_image_entrypoint_command)}" |
There was a problem hiding this comment.
Addressed in commit b978fd8: added unit tests in tests/latest/test_containerapp_debug_unit.py covering URL building (4), command-decorator behavior (4), and the validate_debug validator (4) including the new test_entrypoint_without_image_raises failure case. All 12 unit tests pass locally. Happy to add a recorded test_containerapp_scenario.py case as well if preferred over unit-level coverage.
There was a problem hiding this comment.
Addressed in commit b978fd8: added unit tests in tests/latest/test_containerapp_debug_unit.py covering URL building (4), command-decorator behavior (4), and the validate_debug validator (4) including the new test_entrypoint_without_image_raises failure case. All 12 unit tests pass locally. Happy to add a recorded test_containerapp_scenario.py case as well if preferred over unit-level coverage.
Allow customers to specify a custom container image and entrypoint for the debug ephemeral container via 'az containerapp debug'. - Add --image and --entrypoint optional parameters - Append customDebugImageName and customDebugImageEntrypointCommand query params to the debug URL when provided - Client-side validation: --entrypoint requires --image - Add help examples for the new parameters
eba34bd to
b314ccd
Compare
Tests cover: - URL building without custom image params - URL building with --image only - URL building with --image and --entrypoint - URL encoding of special characters - Client-side validation: --entrypoint without --image raises error - --image without --entrypoint succeeds - No custom params succeeds - Getter methods return correct values - Getter methods return None when not set
…ough containerapp_debug - _validators.validate_debug: reject --image/--entrypoint when --command is missing (interactive mode with custom images is not yet supported server-side) - custom.containerapp_debug: accept and forward custom_debug_image_name and custom_debug_image_entrypoint_command into raw_parameters - tests: add coverage for the new validator branches
…ISTORY - Move --entrypoint requires --image check from execute_Command into validate_debug so it applies to both interactive and non-interactive paths (Copilot review) - Bump containerapp extension VERSION to 1.3.0b5 - Add HISTORY.rst entry for 1.3.0b5 - Update unit tests: drop stale execute_Command validation test, add validate_debug coverage for entrypoint-without-image
|
Thanks for the review! Pushed Bot —
Copilot summary — move Copilot inline — Copilot inline — add tests for new flags + failure case |
Allow customers to specify a custom container image and entrypoint for the debug ephemeral container via
az containerapp debug.--imageand--entrypointoptional parameterscustomDebugImageNameandcustomDebugImageEntrypointCommandquery params to the debug URL when providedvalidate_debug:--entrypointrequires--image;--image/--entrypointrequire--command(interactive custom-image debug not yet supported server-side)VERSIONto1.3.0b5+HISTORY.rstentryTesting
Unit tests —
src/containerapp/azext_containerapp/tests/latest/test_containerapp_debug_unit.py(12 tests, all pass):TestDebugCommandUrlBuilding(4)TestDebugCommandValidation(4)TestValidateDebugCustomImageRequiresCommand(4)validate_debug: image without command raises, entrypoint without command raises, image+command passes, entrypoint without image raises (new)Run locally:
Result:
Ran 12 tests in 0.008s — OK.End-to-end (live) — verified against a real Container App (
ca-debug-test-appinca-debug-test-rg, eastus, sub2819c8c8-...):az --debuglog.Validation negative cases verified manually:
--entrypoint Xwithout--image→ValidationError: --entrypoint requires --image to also be specified.--image Xwithout--command→ValidationError: --image and --entrypoint are only supported with --command. Interactive mode with custom images is not yet supported.This checklist is used to make sure that common guidelines for a pull request are followed.
Related command
az containerapp debugGeneral Guidelines
azdev style <YOUR_EXT>locally? (pip install azdevrequired)python scripts/ci/test_index.py -qlocally? (pip install wheel==0.30.0required)For new extensions:
About Extension Publish
There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update
src/index.jsonautomatically.You only need to update the version information in file setup.py and historical information in file HISTORY.rst in your PR but do not modify
src/index.json.