[AppService] az webapp troubleshoot collect network-capture: Add command to collect network capture - #33949
[AppService] az webapp troubleshoot collect network-capture: Add command to collect network capture#33949Shi1810 wants to merge 4 commits into
az webapp troubleshoot collect network-capture: Add command to collect network capture#33949Conversation
|
Hi Shi1810, |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
az webapp troubleshoot collect network-capture: Add command to collect network capture
az webapp troubleshoot collect network-capture: Add command to collect network captureaz webapp troubleshoot collect network-capture: Add command to collect network capture
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Pull request overview
Adds a new App Service diagnostics CLI command, az webapp troubleshoot collect network-capture, to collect a bounded packet capture from a selected Linux App Service worker instance, trigger Kudu-side analysis, and present links to the resulting artifacts.
Changes:
- Introduces
azure.cli.command_modules.appservice.network_captureimplementing capture creation, websocket-driven capture execution, polling, and result rendering. - Registers the new preview command group/command and wires up parameters (
--instance,--duration,--collect-only). - Adds unit tests validating option validation, instance selection behavior, and mocked end-to-end capture flow.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/azure-cli/azure/cli/command_modules/appservice/network_capture.py | New implementation for creating, running, and summarizing network captures via Kudu/SCM. |
| src/azure-cli/azure/cli/command_modules/appservice/commands.py | Registers webapp troubleshoot collect network-capture command. |
| src/azure-cli/azure/cli/command_modules/appservice/_params.py | Adds CLI arguments for the new command. |
| src/azure-cli/azure/cli/command_modules/appservice/_help.py | Adds help text and examples for the new group/command. |
| src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_network_capture_thru_mock.py | Adds unit tests for validation, instance selection, and capture flow. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| def collect_network_capture(cmd, resource_group_name, name, slot=None, instance=None, duration=60, | ||
| collect_only=False): | ||
| webapp = _generic_site_operation( | ||
| cmd.cli_ctx, resource_group_name, name, 'get', slot) | ||
| if not webapp: | ||
| raise ResourceNotFoundError( | ||
| "Unable to find web app '{}' in resource group '{}'.".format(name, resource_group_name)) | ||
| if not is_linux_webapp(webapp): | ||
| raise ValidationError( | ||
| "Network capture is only supported for Linux web apps on dedicated App Service plans.") | ||
|
|
||
| _validate_capture_options(duration) | ||
| _log_capture_advisory() | ||
| target = _select_target_instance( | ||
| cmd, resource_group_name, name, instance, slot) | ||
|
|
||
| scm_url = _get_scm_url(cmd, resource_group_name, name, slot).rstrip('/') | ||
| headers = get_scm_site_headers( | ||
| cmd.cli_ctx, name, resource_group_name, slot) | ||
| session = _create_http_session(headers, target) |
| _render_capture_summary(result, collect_only) | ||
|
|
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
|
App Service |
Live test results —
|
az webapp troubleshoot collect network-capture: Add command to collect network captureaz webapp troubleshoot collect network-capture: Add command to collect network capture
There was a problem hiding this comment.
Shi1810, the review is not yet passing. Summary of CI, live-test, and review-skill results:
CI failures
Azure.azure-clibuild check — FAILED (PR-related). Build #20260821.44 reported 8 errors / 4 warnings (Azure DevOps log). Since 49/53 checks otherwise passed and the failing build is tied to this PR's commit, this is very likely caused by the changes in this PR (newnetwork_capture.pymodule and the associated command/param wiring underappservice). Please open the Azure DevOps build log to see the specific error list (likely lint/pylint, unit test, or import errors introduced by the new module) and fix them locally, then push a new commit.- Focused re-check: re-run
azdev style appservice && azdev test appservicelocally, then re-request theAzure.azure-clicheck (or push a commit) to retrigger CI.
- Focused re-check: re-run
Check the Format of Pull Request Title and Content— auto-repaired. The PR title did not match the required[Component] Fix #N: \az ...`:format, so it has been automatically updated to[AppService] `az webapp troubleshoot collect network-capture`: Add command to collect network capture` and the title check has been re-requested. No action needed here unless the new title is inaccurate.
Live test: passed (tester ran successfully against this PR's head commit).
Regression coverage: no gap — production changes in _params.py, commands.py, and network_capture.py are covered by the new/updated test_network_capture_thru_mock.py.
Review-skill finding (blocking):
- Release artifact validator — Customer-visible production behavior changed (new
az webapp troubleshoot collect network-capturecommand) without a corresponding release note.- File:
src/azure-cli/azure/cli/command_modules/appservice/_help.py#L2541 - Remediation: Add a release note describing the new command under the
appservicemodule's upcoming-release history (e.g.HISTORY.rst). - Verification: Run the repository's release-note/history validation and confirm the entry appears under the upcoming release.
- File:
Please address the build failure and add the missing release note, then push updates so CI and review can re-run.
|
🔔 Routing this PR to @Azure/act-quality-productivity-squad. |
🤖 PR Validation —⚠️ Review suggested
Related command
az webapp troubleshoot collect network-captureDescription
az webapp troubleshoot collect network-capture
The command collects a bounded packet capture from a selected Linux App Service worker, finalizes and analyzes it through Kudu, and returns authenticated Kudu links for the raw packet capture and analysis report.
User can give --collect-only to display only the raw packet capture link.
Testing Guide
az webapp troubleshoot collect network-capture -g shikhajhatestingrg -n cli-netcap-shot-586211 --instance $instance --duration 10 --collect-only

az webapp troubleshoot collect network-capture -g shikhajhatestingrg -n cli-netcap-shot-586211 --duration 10

az webapp troubleshoot collect network-capture -g shikhajhatestingrg -n cli-netcap-shot-586211 --duration 10
History Notes
[App Service]
az webapp troubleshoot collect network-capture: Add command to collects a bounded packet capture from a selected Linux App Service worker[App Service]
az webapp troubleshoot collect network-capture: Adds --collect-only to display only the raw packet capture link.This 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.