Share via


az network watcher packet-capture

Manage packet capture sessions on VMs.

These commands require that both Azure Network Watcher is enabled for the VMs region and that AzureNetworkWatcherExtension is enabled on the VM. For more information visit https://learn.microsoft.com/en-us/azure/network-watcher/network-watcher-packet-capture-manage-cli.

Commands

Name Description Type Status
az network watcher packet-capture create

Create and start a packet capture session.

Core GA
az network watcher packet-capture delete

Delete a packet capture session.

Core GA
az network watcher packet-capture list

List all packet capture sessions within a region.

Core GA
az network watcher packet-capture show

Show details of a packet capture session.

Core GA
az network watcher packet-capture show-status

Show the status of a packet capture session.

Core GA
az network watcher packet-capture stop

Stop a running packet capture session.

Core GA
az network watcher packet-capture wait

Place the CLI in a waiting state until a condition is met.

Core GA

az network watcher packet-capture create

Experimental Preview Deprecated

Create and start a packet capture session.

az network watcher packet-capture create --name
                                         --resource-group
                                         [--capture-limit]
                                         [--capture-size]
                                         [--exclude]
                                         [--file-path]
                                         [--filters]
                                         [--include]
                                         [--no-wait {0, 1, f, false, n, no, t, true, y, yes}]
                                         [--storage-account]
                                         [--storage-path]
                                         [--target]
                                         [--target-type {AzureVM, AzureVMSS}]
                                         [--time-limit]
                                         [--vm]

Examples

Create a packet capture session on a VM.

az network watcher packet-capture create -g MyResourceGroup -n MyPacketCaptureName --vm MyVm --storage-account MyStorageAccount

Create a packet capture session on a VM with optional filters for protocols, local IP address and remote IP address ranges and ports.

az network watcher packet-capture create -g MyResourceGroup -n MyPacketCaptureName --vm MyVm --storage-account MyStorageAccount --filters '[{"protocol":"TCP", "remoteIPAddress":"1.1.1.1-255.255.255", "localIPAddress":"10.0.0.3", "remotePort":"20"}, {"protocol":"TCP", "remoteIPAddress":"1.1.1.1-255.255.255", "localIPAddress":"10.0.0.3", "remotePort":"80"}, {"protocol":"TCP", "remoteIPAddress":"1.1.1.1-255.255.255", "localIPAddress":"10.0.0.3", "remotePort":"443"}, {"protocol":"UDP"}]'

Create a packet capture session on a VMSS.

az network watcher packet-capture create -g MyResourceGroup -n MyPacketCaptureName --vm MyVmVMSS --storage-account MyStorageAccount --target-type "AzureVMSS"

Create a packet capture session on a VMSS with including particular instances.

az network watcher packet-capture create -g MyResourceGroup -n MyPacketCaptureName --target MyVmVMSS --storage-account MyStorageAccount --target-type "AzureVMSS" --include "0" "1"

Create a packet capture session on a VMSS with excluding particular instances.

az network watcher packet-capture create -g MyResourceGroup -n MyPacketCaptureName --vm MyVmVMSS --storage-account MyStorageAccount --target-type "AzureVMSS" --exclude "0" "1"

Required Parameters

--name -n
Experimental Preview Deprecated

Name of the packet capture session.

--resource-group -g
Experimental Preview Deprecated

Name of the resource group the target resource is in.

Optional Parameters

--capture-limit
Experimental Preview Deprecated

Maximum size in bytes of the capture output.

Default value: 1073741824
--capture-size
Experimental Preview Deprecated

Number of bytes captured per packet. Excess bytes are truncated.

Default value: 0
--exclude
Experimental Preview Deprecated

Space-separated list of VMSS instances to exclude in packet capture. Support shorthand-syntax, json-file and yaml-file. Try "??" to show more.

--file-path
Experimental Preview Deprecated

Local path on the targeted VM at which to save the packet capture. For Linux VMs, the path must start with /var/captures.

--filters
Experimental Preview Deprecated

JSON encoded list of packet filters. Use @{path} to load from file. Support shorthand-syntax, json-file and yaml-file. Try "??" to show more.

--include
Experimental Preview Deprecated

Space-separated list of VMSS instances to include in packet capture like 0 1 2. Support shorthand-syntax, json-file and yaml-file. Try "??" to show more.

--no-wait
Experimental Preview Deprecated

Do not wait for the long-running operation to finish.

Accepted values: 0, 1, f, false, n, no, t, true, y, yes
--storage-account
Experimental Preview Deprecated

Name or ID of a storage account to save the packet capture to.

--storage-path
Experimental Preview Deprecated

Fully qualified URI of an existing storage container in which to store the capture file. If not specified, the container network-watcher-logs will be created if it does not exist and the capture file will be stored there.

--target
Experimental Preview Deprecated

Name or ID of the target resource. If --target-type is AzureVMSS, then --target is mandatory.

--target-type
Experimental Preview Deprecated

Resource type of target.

Accepted values: AzureVM, AzureVMSS
Default value: AzureVM
--time-limit
Experimental Preview Deprecated

Maximum duration of the capture session in seconds.

Default value: 18000
--vm
Experimental Preview Deprecated

Name or ID of the VM to target.

Global Parameters
--debug
Experimental Preview Deprecated

Increase logging verbosity to show all debug logs.

--help -h
Experimental Preview Deprecated

Show this help message and exit.

--only-show-errors
Experimental Preview Deprecated

Only show errors, suppressing warnings.

--output -o
Experimental Preview Deprecated

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query
Experimental Preview Deprecated

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription
Experimental Preview Deprecated

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose
Experimental Preview Deprecated

Increase logging verbosity. Use --debug for full debug logs.

az network watcher packet-capture delete

Experimental Preview Deprecated

Delete a packet capture session.

az network watcher packet-capture delete --location
                                         --name
                                         [--no-wait {0, 1, f, false, n, no, t, true, y, yes}]

Examples

Delete a packet capture session. This only deletes the session and not the capture file.

az network watcher packet-capture delete -n packetCaptureName -l westcentralus

Required Parameters

--location -l
Experimental Preview Deprecated

Location. Values from: az account list-locations. You can configure the default location using az configure --defaults location=<location>.

--name -n
Experimental Preview Deprecated

Name of the packet capture session.

Optional Parameters

--no-wait
Experimental Preview Deprecated

Do not wait for the long-running operation to finish.

Accepted values: 0, 1, f, false, n, no, t, true, y, yes
Global Parameters
--debug
Experimental Preview Deprecated

Increase logging verbosity to show all debug logs.

--help -h
Experimental Preview Deprecated

Show this help message and exit.

--only-show-errors
Experimental Preview Deprecated

Only show errors, suppressing warnings.

--output -o
Experimental Preview Deprecated

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query
Experimental Preview Deprecated

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription
Experimental Preview Deprecated

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose
Experimental Preview Deprecated

Increase logging verbosity. Use --debug for full debug logs.

az network watcher packet-capture list

Experimental Preview Deprecated

List all packet capture sessions within a region.

az network watcher packet-capture list --location

Examples

List all packet capture sessions within a region.

az az network watcher packet-capture list -l westus

Required Parameters

--location -l
Experimental Preview Deprecated

Location. Values from: az account list-locations. You can configure the default location using az configure --defaults location=<location>.

Optional Parameters

Global Parameters
--debug
Experimental Preview Deprecated

Increase logging verbosity to show all debug logs.

--help -h
Experimental Preview Deprecated

Show this help message and exit.

--only-show-errors
Experimental Preview Deprecated

Only show errors, suppressing warnings.

--output -o
Experimental Preview Deprecated

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query
Experimental Preview Deprecated

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription
Experimental Preview Deprecated

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose
Experimental Preview Deprecated

Increase logging verbosity. Use --debug for full debug logs.

az network watcher packet-capture show

Experimental Preview Deprecated

Show details of a packet capture session.

az network watcher packet-capture show --location
                                       --name

Examples

Show a packet capture session.

az network watcher packet-capture show -l westus -n MyPacketCapture

Required Parameters

--location -l
Experimental Preview Deprecated

Location. Values from: az account list-locations. You can configure the default location using az configure --defaults location=<location>.

--name -n
Experimental Preview Deprecated

Name of the packet capture session.

Optional Parameters

Global Parameters
--debug
Experimental Preview Deprecated

Increase logging verbosity to show all debug logs.

--help -h
Experimental Preview Deprecated

Show this help message and exit.

--only-show-errors
Experimental Preview Deprecated

Only show errors, suppressing warnings.

--output -o
Experimental Preview Deprecated

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query
Experimental Preview Deprecated

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription
Experimental Preview Deprecated

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose
Experimental Preview Deprecated

Increase logging verbosity. Use --debug for full debug logs.

az network watcher packet-capture show-status

Experimental Preview Deprecated

Show the status of a packet capture session.

az network watcher packet-capture show-status --location
                                              --name
                                              [--no-wait {0, 1, f, false, n, no, t, true, y, yes}]

Examples

Show the status of a packet capture session.

az network watcher packet-capture show-status -l westus -n MyPacketCapture

Required Parameters

--location -l
Experimental Preview Deprecated

Location. Values from: az account list-locations. You can configure the default location using az configure --defaults location=<location>.

--name -n
Experimental Preview Deprecated

Name given to the packet capture session.

Optional Parameters

--no-wait
Experimental Preview Deprecated

Do not wait for the long-running operation to finish.

Accepted values: 0, 1, f, false, n, no, t, true, y, yes
Global Parameters
--debug
Experimental Preview Deprecated

Increase logging verbosity to show all debug logs.

--help -h
Experimental Preview Deprecated

Show this help message and exit.

--only-show-errors
Experimental Preview Deprecated

Only show errors, suppressing warnings.

--output -o
Experimental Preview Deprecated

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query
Experimental Preview Deprecated

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription
Experimental Preview Deprecated

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose
Experimental Preview Deprecated

Increase logging verbosity. Use --debug for full debug logs.

az network watcher packet-capture stop

Experimental Preview Deprecated

Stop a running packet capture session.

az network watcher packet-capture stop --location
                                       --name
                                       [--no-wait {0, 1, f, false, n, no, t, true, y, yes}]

Examples

Stop a running packet capture session.

az network watcher packet-capture stop -l westus -n MyPacketCapture

Required Parameters

--location -l
Experimental Preview Deprecated

Location. Values from: az account list-locations. You can configure the default location using az configure --defaults location=<location>.

--name -n
Experimental Preview Deprecated

Name of the packet capture session.

Optional Parameters

--no-wait
Experimental Preview Deprecated

Do not wait for the long-running operation to finish.

Accepted values: 0, 1, f, false, n, no, t, true, y, yes
Global Parameters
--debug
Experimental Preview Deprecated

Increase logging verbosity to show all debug logs.

--help -h
Experimental Preview Deprecated

Show this help message and exit.

--only-show-errors
Experimental Preview Deprecated

Only show errors, suppressing warnings.

--output -o
Experimental Preview Deprecated

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query
Experimental Preview Deprecated

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription
Experimental Preview Deprecated

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose
Experimental Preview Deprecated

Increase logging verbosity. Use --debug for full debug logs.

az network watcher packet-capture wait

Experimental Preview Deprecated

Place the CLI in a waiting state until a condition is met.

az network watcher packet-capture wait [--created]
                                       [--custom]
                                       [--deleted]
                                       [--exists]
                                       [--ids]
                                       [--interval]
                                       [--name]
                                       [--subscription]
                                       [--timeout]
                                       [--updated]
                                       [--watcher-name]
                                       [--watcher-rg]

Examples

Required Parameters

Optional Parameters

--created
Experimental Preview Deprecated

Wait until created with 'provisioningState' at 'Succeeded'.

Default value: False
--custom
Experimental Preview Deprecated

Wait until the condition satisfies a custom JMESPath query. E.g. provisioningState!='InProgress', instanceView.statuses[?code=='PowerState/running'].

--deleted
Experimental Preview Deprecated

Wait until deleted.

Default value: False
--exists
Experimental Preview Deprecated

Wait until the resource exists.

Default value: False
--ids
Experimental Preview Deprecated

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--interval
Experimental Preview Deprecated

Polling interval in seconds.

Default value: 30
--name -n
Experimental Preview Deprecated

Name of the packet capture session.

--subscription
Experimental Preview Deprecated

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--timeout
Experimental Preview Deprecated

Maximum wait in seconds.

Default value: 3600
--updated
Experimental Preview Deprecated

Wait until updated with provisioningState at 'Succeeded'.

Default value: False
--watcher-name
Experimental Preview Deprecated

Name of the network watcher.

--watcher-rg
Experimental Preview Deprecated

Name of the resource group the watcher is in.

Global Parameters
--debug
Experimental Preview Deprecated

Increase logging verbosity to show all debug logs.

--help -h
Experimental Preview Deprecated

Show this help message and exit.

--only-show-errors
Experimental Preview Deprecated

Only show errors, suppressing warnings.

--output -o
Experimental Preview Deprecated

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query
Experimental Preview Deprecated

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription
Experimental Preview Deprecated

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose
Experimental Preview Deprecated

Increase logging verbosity. Use --debug for full debug logs.