Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions src/azure-cli/azure/cli/command_modules/appservice/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -2538,6 +2538,48 @@
structured payload that works with `-o json`, `-o yaml`, and `-o table`.
"""

helps['webapp troubleshoot collect'] = """
type: group
short-summary: Collect diagnostic artifacts from a Linux web app.
"""

helps['webapp troubleshoot collect cpu-profiler-trace'] = """
type: command
short-summary: Collect and analyze a CPU profile from a Node.js process.
long-summary: |
Collects a CPU profile from one Node.js process on a selected Linux web app instance.
Kudu supplies the runtime-specific collection command, analyzes the resulting profile,
and stores the raw profile and HTML report under its diagnostics history.

The command returns structured Kudu links for the raw artifact, generated report, and
CPU diagnostics page. Diagnostic artifacts can contain sensitive application data.
Kudu diagnostics must be enabled and the app must use a supported Node.js runtime.
examples:
- name: Collect a 30-second CPU profile
text: az webapp troubleshoot collect cpu-profiler-trace -g MyResourceGroup -n MyWebApp
- name: Profile a specific process on a specific worker for 60 seconds
text: az webapp troubleshoot collect cpu-profiler-trace -g MyResourceGroup -n MyWebApp --instance MyInstanceId --process-id 42 --duration 60
"""

helps['webapp troubleshoot collect memory-dumps'] = """
type: command
short-summary: Collect and analyze a memory dump from a Node.js process.
long-summary: |
Collects a V8 heap snapshot from one Node.js process on a selected Linux web app instance.
Kudu supplies the runtime-specific collection command, analyzes the resulting snapshot,
and stores the raw snapshot and HTML report under its diagnostics history.

The command returns structured Kudu links for the raw artifact, generated report, and
memory diagnostics page. Heap snapshots can contain sensitive application data and
collection can briefly affect application responsiveness. Kudu diagnostics must be
enabled and the app must use a supported Node.js runtime.
examples:
- name: Collect a memory dump
text: az webapp troubleshoot collect memory-dumps -g MyResourceGroup -n MyWebApp
- name: Collect a memory dump from a specific process and worker
text: az webapp troubleshoot collect memory-dumps -g MyResourceGroup -n MyWebApp --instance MyInstanceId --process-id 42
"""

helps['functionapp log'] = """
type: group
short-summary: Manage function app logs.
Expand Down
15 changes: 15 additions & 0 deletions src/azure-cli/azure/cli/command_modules/appservice/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,21 @@ def load_arguments(self, _):
c.argument('instance', options_list=['--instance'], help="Scope the report to a single worker instance. Accepts either the ARM instanceId or the machine name (e.g. `lw0sdlwk0007AB`). When omitted, returns an overview of every instance seen in the last 24 hours.")
c.argument('report', options_list=['--report'], arg_type=get_three_state_flag(), help="Print a human-readable, color-coded report to stdout instead of returning the structured payload.")

for command_name in ('cpu-profiler-trace', 'memory-dumps'):
with self.argument_context('webapp troubleshoot collect ' + command_name) as c:
c.argument('name', arg_type=webapp_name_arg_type, id_part=None)
c.argument('resource_group', arg_type=resource_group_name_type)
c.argument('slot', options_list=['--slot', '-s'],
help='Name of the web app slot. Defaults to the production slot.')
c.argument('instance', options_list=['--instance', '-i'],
help='Worker instance to diagnose. When omitted, a single instance is selected automatically or you are prompted when multiple instances are running.')
c.argument('process_id', options_list=['--process-id'], type=int,
help='Process ID of the Node.js process to diagnose. When omitted, a single eligible process is selected automatically or you are prompted when multiple processes are running.')

with self.argument_context('webapp troubleshoot collect cpu-profiler-trace') as c:
c.argument('duration', options_list=['--duration'], type=int, default=30,
help='CPU profiling duration in seconds. Valid range: 5-300.')

with self.argument_context('functionapp log deployment show') as c:
c.argument('name', arg_type=functionapp_name_arg_type, id_part=None)
c.argument('resource_group', arg_type=resource_group_name_type)
Expand Down
11 changes: 11 additions & 0 deletions src/azure-cli/azure/cli/command_modules/appservice/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ def load_command_table(self, _):

webapp_exec_custom = CliCommandType(operations_tmpl='azure.cli.command_modules.appservice.webapp_exec#{}')

node_diagnostics_custom = CliCommandType(
operations_tmpl='azure.cli.command_modules.appservice.node_diagnostics#{}')

with self.command_group('webapp', webapp_sdk) as g:
g.custom_command('create', 'create_webapp', exception_handler=ex_handler_factory(), validator=validate_vnet_integration)
g.custom_command('up', 'webapp_up', exception_handler=ex_handler_factory(), validator=validate_webapp_up,
Expand Down Expand Up @@ -349,6 +352,14 @@ def load_command_table(self, _):
g.custom_command('status', 'troubleshoot_status',
table_transformer=transform_troubleshoot_status_output)

with self.command_group('webapp troubleshoot collect', is_preview=True) as g:
g.custom_command('cpu-profiler-trace', 'collect_cpu_profiler_trace',
custom_command_type=node_diagnostics_custom,
exception_handler=ex_handler_factory())
g.custom_command('memory-dumps', 'collect_memory_dump',
custom_command_type=node_diagnostics_custom,
exception_handler=ex_handler_factory())

with self.command_group('functionapp log deployment') as g:
g.custom_show_command('show', 'show_deployment_log')
g.custom_command('list', 'list_deployment_logs')
Expand Down
Loading
Loading