你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

az network watcher packet-capture

管理 VM 上的数据包捕获会话。

这些命令要求为 VM 区域启用 Azure 网络观察程序,并在 VM 上启用 AzureNetworkWatcherExtension。 有关详细信息,请访问 https://learn.microsoft.com/en-us/azure/network-watcher/network-watcher-packet-capture-manage-cli

命令

名称 说明 类型 状态
az network watcher packet-capture create

创建并启动数据包捕获会话。

核心 GA
az network watcher packet-capture delete

删除数据包捕获会话。

核心 GA
az network watcher packet-capture list

列出区域中的所有数据包捕获会话。

核心 GA
az network watcher packet-capture show

显示数据包捕获会话的详细信息。

核心 GA
az network watcher packet-capture show-status

显示数据包捕获会话的状态。

核心 GA
az network watcher packet-capture stop

停止正在运行的数据包捕获会话。

核心 GA
az network watcher packet-capture wait

将 CLI 置于等待状态,直到满足条件。

核心 GA

az network watcher packet-capture create

创建并启动数据包捕获会话。

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]

示例

在 VM 上创建数据包捕获会话。

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

在 VM 上创建数据包捕获会话,其中包含协议、本地 IP 地址和远程 IP 地址范围和端口的可选筛选器。

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"}]'

在 VMSS 上创建数据包捕获会话。

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

在包含特定实例的 VMSS 上创建数据包捕获会话。

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

在包含排除特定实例的 VMSS 上创建数据包捕获会话。

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

必需参数

--name -n

数据包捕获会话的名称。

--resource-group -g

目标资源位于的资源组的名称。

可选参数

--capture-limit

捕获输出的最大大小(以字节为单位)。

默认值: 1073741824
--capture-size

每个数据包捕获的字节数。 将截断多余的字节。

默认值: 0
--exclude

在数据包捕获中要排除的 VMSS 实例的空间分隔列表。 支持速记语法、json-file 和 yaml-file。 请尝试“??” 以显示更多内容。

--file-path

要在其中保存数据包捕获的目标 VM 上的本地路径。 对于 Linux VM,路径必须以 /var/captures.

--filters

数据包筛选器的 JSON 编码列表。 用于 @{path} 从文件加载。 支持速记语法、json-file 和 yaml-file。 请尝试“??” 以显示更多内容。

--include

要包括在数据包捕获中的 VMSS 实例的空间分隔列表,例如 0 1 2。 支持速记语法、json-file 和 yaml-file。 请尝试“??” 以显示更多内容。

--no-wait

不等待长时间运行的操作完成。

接受的值: 0, 1, f, false, n, no, t, true, y, yes
--storage-account

存储帐户的名称或 ID,用于将数据包捕获保存到其中。

--storage-path

要在其中存储捕获文件的现有存储容器的完全限定 URI。 如果未指定,则创建容器 network-watcher-logs (如果不存在),并将在那里存储捕获文件。

--target

目标资源的名称或 ID。 如果是 --target-type AzureVMSS,则 --target 是必需的。

--target-type

目标的资源类型。

接受的值: AzureVM, AzureVMSS
默认值: AzureVM
--time-limit

捕获会话的最大持续时间(以秒为单位)。

默认值: 18000
--vm

要面向的 VM 的名称或 ID。

全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。

az network watcher packet-capture delete

删除数据包捕获会话。

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

示例

删除数据包捕获会话。 这只会删除会话,而不是捕获文件。

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

必需参数

--location -l

Location。 az account list-locations 中的值。 可以使用 az configure --defaults location=<location> 配置默认位置。

--name -n

数据包捕获会话的名称。

可选参数

--no-wait

不等待长时间运行的操作完成。

接受的值: 0, 1, f, false, n, no, t, true, y, yes
全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。

az network watcher packet-capture list

列出区域中的所有数据包捕获会话。

az network watcher packet-capture list --location

示例

列出区域中的所有数据包捕获会话。

az az network watcher packet-capture list -l westus

必需参数

--location -l

Location。 az account list-locations 中的值。 可以使用 az configure --defaults location=<location> 配置默认位置。

全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。

az network watcher packet-capture show

显示数据包捕获会话的详细信息。

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

示例

显示数据包捕获会话。

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

必需参数

--location -l

Location。 az account list-locations 中的值。 可以使用 az configure --defaults location=<location> 配置默认位置。

--name -n

数据包捕获会话的名称。

全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。

az network watcher packet-capture show-status

显示数据包捕获会话的状态。

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

示例

显示数据包捕获会话的状态。

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

必需参数

--location -l

Location。 az account list-locations 中的值。 可以使用 az configure --defaults location=<location> 配置默认位置。

--name -n

为数据包捕获会话指定的名称。

可选参数

--no-wait

不等待长时间运行的操作完成。

接受的值: 0, 1, f, false, n, no, t, true, y, yes
全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。

az network watcher packet-capture stop

停止正在运行的数据包捕获会话。

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

示例

停止正在运行的数据包捕获会话。

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

必需参数

--location -l

Location。 az account list-locations 中的值。 可以使用 az configure --defaults location=<location> 配置默认位置。

--name -n

数据包捕获会话的名称。

可选参数

--no-wait

不等待长时间运行的操作完成。

接受的值: 0, 1, f, false, n, no, t, true, y, yes
全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。

az network watcher packet-capture wait

将 CLI 置于等待状态,直到满足条件。

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

可选参数

--created

等待在“Succeeded”中使用“provisioningState”创建。

默认值: False
--custom

等待条件满足自定义 JMESPath 查询。 例如 provisioningState!='InProgress', instanceView.statuses[?code=='PowerState/running']。

--deleted

等到删除为止。

默认值: False
--exists

等待资源存在。

默认值: False
--ids

一个或多个资源 ID(空格分隔)。 它应该是包含“资源 ID”参数的所有信息的完整资源 ID。 应提供 --id 或其他“资源 ID”参数。

--interval

轮询间隔(以秒为单位)。

默认值: 30
--name -n

数据包捕获会话的名称。

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--timeout

最大等待(以秒为单位)。

默认值: 3600
--updated

等到 provisioningState 更新为“Succeeded”。

默认值: False
--watcher-name

网络观察程序的名称。

--watcher-rg

观察程序在其中的资源组的名称。

全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。