Share via


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

命令

名稱 Description 類型 狀態
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

要儲存封包擷取的儲存體帳戶名稱或識別碼。

--storage-path

用來儲存擷取檔案之現有儲存體容器的完整 URI。 如果未指定, network-watcher-logs 則會在容器不存在且擷取檔案儲存于該處時建立。

--target

目標資源的名稱或識別碼。 如果 --target-type 是 AzureVMSS,則 --target 為必要專案。

--target-type

目標的資源類型。

接受的值: AzureVM, AzureVMSS
預設值: AzureVM
--time-limit

擷取會話的持續時間上限,以秒為單位。

預設值: 18000
--vm

要設為目標的 VM 名稱或識別碼。

全域參數
--debug

增加記錄詳細資訊,以顯示所有偵錯記錄。

--help -h

顯示此說明訊息並結束。

--only-show-errors

只顯示錯誤,隱藏警告。

--output -o

輸出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
預設值: json
--query

JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/

--subscription

訂用帳戶的名稱或識別碼。 您可以使用 來設定預設訂用 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

位置。​​ 來自的值: 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

訂用帳戶的名稱或識別碼。 您可以使用 來設定預設訂用 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

位置。​​ 來自的值: 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

訂用帳戶的名稱或識別碼。 您可以使用 來設定預設訂用 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

位置。​​ 來自的值: 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

訂用帳戶的名稱或識別碼。 您可以使用 來設定預設訂用 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

位置。​​ 來自的值: 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

訂用帳戶的名稱或識別碼。 您可以使用 來設定預設訂用 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

位置。​​ 來自的值: 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

訂用帳戶的名稱或識別碼。 您可以使用 來設定預設訂用 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

一或多個資源識別碼 (以空格分隔)。 它應該是包含 「資源識別碼」引數所有資訊的完整資源識別碼。 您應該提供 --ids 或其他「資源識別碼」引數。

--interval

輪詢間隔以秒為單位。

預設值: 30
--name -n

封包擷取會話的名稱。

--subscription

訂用帳戶的名稱或識別碼。 您可以使用 來設定預設訂用 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

訂用帳戶的名稱或識別碼。 您可以使用 來設定預設訂用 az account set -s NAME_OR_ID 帳戶。

--verbose

增加記錄詳細資訊。 使用 --debug 來取得完整偵錯記錄。