Skip to content

[AppService] az webapp troubleshoot collect network-capture: Add command to collect network capture - #33949

Open
Shi1810 wants to merge 4 commits into
Azure:devfrom
Shi1810:user/shikhajha/networkcapture
Open

[AppService] az webapp troubleshoot collect network-capture: Add command to collect network capture#33949
Shi1810 wants to merge 4 commits into
Azure:devfrom
Shi1810:user/shikhajha/networkcapture

Conversation

@Shi1810

@Shi1810 Shi1810 commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

🤖 PR Validation — ⚠️ Review suggested

Breaking Changes Tests
⚠️ None ️✔️ 130/130
⚠️AzureCLI-BreakingChangeTest
⚠️appservice
rule cmd_name rule_message suggest_message
⚠️ 1011 - SubgroupAdd webapp troubleshoot collect sub group webapp troubleshoot collect added

Related command
az webapp troubleshoot collect network-capture

Description
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
image

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

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

image

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.

@azure-client-tools-bot-prd

Copy link
Copy Markdown

Hi Shi1810,
Since the current milestone time is less than 7 days, this pr may not catch up with this release.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

@Shi1810 Shi1810 changed the title add network capture [App Service]az webapp troubleshoot collect network-capture: Add command to collect network capture Aug 21, 2026
@Shi1810 Shi1810 changed the title [App Service]az webapp troubleshoot collect network-capture: Add command to collect network capture [App Service] az webapp troubleshoot collect network-capture: Add command to collect network capture Aug 21, 2026
@Shi1810
Shi1810 marked this pull request as ready for review August 21, 2026 19:15
@Shi1810
Shi1810 requested a review from a team as a code owner August 21, 2026 19:15
Copilot AI lite review requested due to automatic review settings August 21, 2026 19:15
@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.

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_capture implementing 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.

Comment on lines +27 to +46
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)
Comment on lines +88 to +89
_render_capture_summary(result, collect_only)

@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

App Service

@a0x1ab Aditya Pujara (a0x1ab) added the Azure Client Tools Agent Requested Request Azure Client Tools Agent testing and review label Aug 22, 2026
@azure-client-tools-agent

Copy link
Copy Markdown
Contributor

Live test results — azdev test --live --series (changed test files only)

PASS

Selectors: test_network_capture_thru_mock (module)
PR head ref: user/shikhajha/networkcapture
PR head sha: fcea55841a813bfd209fb8f0ef0279d573b2f33b
PR base ref: dev
New test files in PR: true

Changed test files run
src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_network_capture_thru_mock.py

New test files
src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_network_capture_thru_mock.py

Workflow run: https://github.com/Azure/issue-sentinel/actions/runs/32563608769

Last 80 lines of azdev output

=============
| Run Tests |
=============


=====================
| Discovering Tests |
=====================

/home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py:13640: SyntaxWarning: invalid escape sequence '\]'
  self.cmd('vmss application set -g {rg} -n {vmss} --app-version-ids {vid1} {vid2} --enable-automatic-upgrade True\]', checks=[
/home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli/azure/cli/command_modules/identity/tests/latest/test_identity.py:18: SyntaxWarning: invalid escape sequence '\{'
  'resource_restriction_compute': '\{"providers":\["Microsoft.Compute"\]\}',
/home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli/azure/cli/command_modules/identity/tests/latest/test_identity.py:19: SyntaxWarning: invalid escape sequence '\{'
  'resource_restriction_empty': '\{"providers":\[\]\}'

test index updated: /home/runner/.azdev/env_config/home/runner/work/issue-sentinel/issue-sentinel/.venv/test_index/latest.json

Test on modules: test_network_capture_thru_mock

WARNING: RUNNING TESTS LIVE
The tests are set to run against current profile "latest"
============================= test session starts ==============================
platform linux -- Python 3.12.14, pytest-9.1.1, pluggy-1.6.0 -- /home/runner/work/issue-sentinel/issue-sentinel/.venv/bin/python
cachedir: .pytest_cache
rootdir: /home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli
plugins: forked-1.7.5, xdist-3.8.0
collecting ... collected 11 items

azure-cli/src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_network_capture_thru_mock.py::NetworkCaptureValidationTest::test_accepts_maximum_duration PASSED [  9%]
azure-cli/src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_network_capture_thru_mock.py::NetworkCaptureValidationTest::test_rejects_values_outside_kudu_limits PASSED [ 18%]
azure-cli/src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_network_capture_thru_mock.py::NetworkCaptureInstanceSelectionTest::test_explicit_instance_bypasses_prompt PASSED [ 27%]
azure-cli/src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_network_capture_thru_mock.py::NetworkCaptureInstanceSelectionTest::test_omitted_instance_prompts_with_current_workers PASSED [ 36%]
azure-cli/src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_network_capture_thru_mock.py::NetworkCaptureInstanceSelectionTest::test_omitted_instance_requires_flag_without_tty PASSED [ 45%]
azure-cli/src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_network_capture_thru_mock.py::NetworkCaptureInstanceSelectionTest::test_rejects_all_instances PASSED [ 54%]
azure-cli/src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_network_capture_thru_mock.py::CollectNetworkCaptureTest::test_collect_only_omits_report_link PASSED [ 63%]
azure-cli/src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_network_capture_thru_mock.py::CollectNetworkCaptureTest::test_collects_analyzes_and_returns_kudu_links PASSED [ 72%]
azure-cli/src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_network_capture_thru_mock.py::CollectNetworkCaptureTest::test_no_packets_omits_report_link PASSED [ 81%]
azure-cli/src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_network_capture_thru_mock.py::CollectNetworkCaptureTest::test_surfaces_analysis_failure PASSED [ 90%]
azure-cli/src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_network_capture_thru_mock.py::CaptureShellTest::test_connection_close_after_submission_is_not_a_capture_failure PASSED [100%]

- generated xml file: /home/runner/work/issue-sentinel/issue-sentinel/test-output/results.xml -
============================== 11 passed in 0.44s ==============================

Posted by agent-assist live-test workflow.

@azure-client-tools-agent azure-client-tools-agent Bot changed the title [App Service] az webapp troubleshoot collect network-capture: Add command to collect network capture [AppService] az webapp troubleshoot collect network-capture: Add command to collect network capture Aug 22, 2026

@azure-client-tools-agent azure-client-tools-agent Bot 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.

Shi1810, the review is not yet passing. Summary of CI, live-test, and review-skill results:

CI failures

  1. Azure.azure-cli build 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 (new network_capture.py module and the associated command/param wiring under appservice). 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 appservice locally, then re-request the Azure.azure-cli check (or push a commit) to retrigger CI.
  2. 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-capture command) 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 appservice module'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.

Please address the build failure and add the missing release note, then push updates so CI and review can re-run.

@azure-client-tools-agent azure-client-tools-agent Bot added azure-client-tools-agent Pull request reviewed by Azure Client Tools Agent and removed Azure Client Tools Agent Requested Request Azure Client Tools Agent testing and review labels Aug 22, 2026
@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

🔔 Routing this PR to @Azure/act-quality-productivity-squad.

@a0x1ab Aditya Pujara (a0x1ab) added the Azure Client Tools Agent Requested Request Azure Client Tools Agent testing and review label Aug 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

act-quality-productivity-squad Auto-Assign Auto assign by bot Azure Client Tools Agent Requested Request Azure Client Tools Agent testing and review azure-client-tools-agent Pull request reviewed by Azure Client Tools Agent Network az network vnet/lb/nic/dns/etc...

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants