az network watcher flow-log
管理网络安全组流日志记录。
有关配置流日志的详细信息,请访问 https://learn.microsoft.com/azure/network-watcher/network-watcher-nsg-flow-logging-cli。
命令
名称 | 说明 | 类型 | Status |
---|---|---|---|
az network watcher flow-log create |
在网络安全组上创建流日志。 |
Core | GA |
az network watcher flow-log delete |
删除指定的流日志资源。 |
Core | GA |
az network watcher flow-log list |
列出指定网络观察程序的所有流日志资源。 |
Core | GA |
az network watcher flow-log show |
获取网络安全组的流日志配置。 |
Core | GA |
az network watcher flow-log update |
更新网络安全组的流日志配置。 |
Core | GA |
az network watcher flow-log wait |
将 CLI 置于等待状态,直到满足条件。 |
Core | GA |
az network watcher flow-log create
在网络安全组上创建流日志。
az network watcher flow-log create --name
[--enabled {0, 1, f, false, n, no, t, true, y, yes}]
[--filtering-criteria]
[--format {JSON}]
[--identity]
[--interval]
[--location]
[--log-version]
[--nic]
[--no-wait {0, 1, f, false, n, no, t, true, y, yes}]
[--nsg]
[--resource-group]
[--retention]
[--storage-account]
[--subnet]
[--tags]
[--traffic-analytics {0, 1, f, false, n, no, t, true, y, yes}]
[--user-assigned-identity]
[--vnet]
[--workspace]
示例
使用网络安全组名称创建流日志
az network watcher flow-log create --location westus --resource-group MyResourceGroup --name MyFlowLog --nsg MyNetworkSecurityGroupName --storage-account account
使用 VNet 名称创建流日志
az network watcher flow-log create --location westus --resource-group MyResourceGroup --name MyFlowLog --vnet MyVNetName --storage-account account
使用子网名称创建流日志
az network watcher flow-log create --location westus --resource-group MyResourceGroup --name MyFlowLog --vnet MyVNetName --subnet MySubnetName --storage-account account
使用 NIC 名称创建流日志
az network watcher flow-log create --location westus --resource-group MyResourceGroup --name MyFlowLog --nic MyNICName --storage-account account
使用网络安全组 ID 创建流日志(可能位于其他资源组中)
az network watcher flow-log create --location westus --name MyFlowLog --nsg MyNetworkSecurityGroupID --storage-account account
使用虚拟网络 ID 创建流日志(可能位于其他资源组中)
az network watcher flow-log create --location westus --name MyFlowLog --vnet MyVNetID --storage-account account
使用子网 ID 创建流日志(可能位于其他资源组中)
az network watcher flow-log create --location westus --name MyFlowLog --subnet SubnetID --storage-account account
使用网络接口 ID 创建流日志(可能位于其他资源组中)
az network watcher flow-log create --location westus --name MyFlowLog --nic MyNetworkInterfaceID --storage-account account
创建或更新流日志
az network watcher flow-log create --location westus --resource-group MtRGContainingVNet --name MyVNetName-flowlog --vnet MyVNetName --storage-account MyStorageAccountName --filtering-criteria "dstip=20.252.145.59 || DstPort=443"
必需参数
流记录器的名称。
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
Enable logging. Default: true.
属性 | 值 |
---|---|
接受的值: | 0, 1, f, false, n, no, t, true, y, yes |
可选字段,用于基于 SrcIP、SrcPort、DstIP、DstPort、协议、加密、方向和操作筛选流日志。 如果未指定,将记录所有流日志。
属性 | 值 |
---|---|
Parameter group: | Properties Arguments |
流日志的文件类型。
属性 | 值 |
---|---|
Parameter group: | Format Arguments |
接受的值: | JSON |
FlowLog 资源托管标识支持速记语法、json-file 和 yaml-file。 请尝试“??” 以显示更多内容。
属性 | 值 |
---|---|
Parameter group: | Parameters Arguments |
执行流分析的间隔(以分钟为单位)。 暂时允许的值为 10 和 60。
属性 | 值 |
---|---|
Parameter group: | Traffic Analytics Arguments |
默认值: | 60 |
用于标识区域下独占网络观察程序的位置。 每个订阅和区域只能存在一个网络观察程序。 如果未指定,将使用资源组的位置。
流日志的版本(修订版)。
属性 | 值 |
---|---|
Parameter group: | Format Arguments |
默认值: | 0 |
网络接口 (NIC) 资源的名称或 ID。
不等待长时间运行的操作完成。
属性 | 值 |
---|---|
接受的值: | 0, 1, f, false, n, no, t, true, y, yes |
网络安全组的名称或 ID。
资源组的名称。 可以使用 az configure --defaults group=<name>
配置默认组。
保留日志的天数。
要在其中保存流日志的存储帐户的名称或 ID。 必须位于流日志的同一区域。
子网的名称或 ID。
空格分隔标记:key[=value] [key[=value] ...]。使用“”清除现有标记。 支持速记语法、json-file 和 yaml-file。 请尝试“??” 以显示更多内容。
启用流量分析。 如果提供了 --workspace
,则默认值为 true。
属性 | 值 |
---|---|
Parameter group: | Traffic Analytics Arguments |
接受的值: | 0, 1, f, false, n, no, t, true, y, yes |
ManagedIdentity 资源的名称或 ID。
虚拟网络资源的名称或 ID。
Log Analytics 工作区的名称或 ID。 必须位于流日志的同一区域。
属性 | 值 |
---|---|
Parameter group: | Traffic Analytics Arguments |
全局参数
提高日志记录详细程度以显示所有调试日志。
属性 | 值 |
---|---|
默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
属性 | 值 |
---|---|
默认值: | False |
Output format.
属性 | 值 |
---|---|
默认值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID
配置默认订阅。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
属性 | 值 |
---|---|
默认值: | False |
az network watcher flow-log delete
删除指定的流日志资源。
az network watcher flow-log delete --name
[--location]
[--no-wait {0, 1, f, false, n, no, t, true, y, yes}]
示例
删除指定的流日志资源。
az network watcher flow-log delete --location westus2 --name MyFlowLogger
必需参数
流记录器的名称。
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
用于标识区域下独占网络观察程序的位置。 每个订阅和区域只能存在一个网络观察程序。 如果未指定,将使用资源组的位置。
不等待长时间运行的操作完成。
属性 | 值 |
---|---|
接受的值: | 0, 1, f, false, n, no, t, true, y, yes |
全局参数
提高日志记录详细程度以显示所有调试日志。
属性 | 值 |
---|---|
默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
属性 | 值 |
---|---|
默认值: | False |
Output format.
属性 | 值 |
---|---|
默认值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID
配置默认订阅。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
属性 | 值 |
---|---|
默认值: | False |
az network watcher flow-log list
列出指定网络观察程序的所有流日志资源。
az network watcher flow-log list [--location]
[--max-items]
[--next-token]
示例
列出指定网络观察程序的所有流日志资源。
az network watcher flow-log list --location westus2
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
用于标识区域下独占网络观察程序的位置。 每个订阅和区域只能存在一个网络观察程序。 如果未指定,将使用资源组的位置。
命令输出中要返回的项总数。 如果可用的项总数大于指定的值,则会在命令的输出中提供令牌。 若要恢复分页,请在后续命令的 --next-token
参数中提供令牌值。
属性 | 值 |
---|---|
Parameter group: | Pagination Arguments |
用于指定开始分页的位置的令牌。 这是先前截断的响应中的令牌值。
属性 | 值 |
---|---|
Parameter group: | Pagination Arguments |
全局参数
提高日志记录详细程度以显示所有调试日志。
属性 | 值 |
---|---|
默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
属性 | 值 |
---|---|
默认值: | False |
Output format.
属性 | 值 |
---|---|
默认值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID
配置默认订阅。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
属性 | 值 |
---|---|
默认值: | False |
az network watcher flow-log show
获取网络安全组的流日志配置。
az network watcher flow-log show [--location]
[--name]
[--nsg]
[--resource-group]
示例
显示 NSG 流日志。 (Deprecated)
az network watcher flow-log show -g MyResourceGroup --nsg MyNsg
显示采用 Azure 资源管理格式的 NSG 流日志。
az network watcher flow-log show --location MyNetworkWatcher --name MyFlowLog
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
用于标识区域下独占网络观察程序的位置。 每个订阅和区域只能存在一个网络观察程序。
流记录器的名称。
参数“nsg”已弃用,将在将来的版本中删除。 请改用“--location 和 --name 组合”。
网络安全组的名称或 ID。
资源组的名称。 可以使用 az configure --defaults group=<name>
配置默认组。
全局参数
提高日志记录详细程度以显示所有调试日志。
属性 | 值 |
---|---|
默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
属性 | 值 |
---|---|
默认值: | False |
Output format.
属性 | 值 |
---|---|
默认值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID
配置默认订阅。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
属性 | 值 |
---|---|
默认值: | False |
az network watcher flow-log update
更新网络安全组的流日志配置。
az network watcher flow-log update --location
--name
[--add]
[--enabled {0, 1, f, false, n, no, t, true, y, yes}]
[--filtering-criteria]
[--force-string {0, 1, f, false, n, no, t, true, y, yes}]
[--format {JSON}]
[--identity]
[--interval]
[--log-version]
[--nic]
[--no-wait {0, 1, f, false, n, no, t, true, y, yes}]
[--nsg]
[--remove]
[--resource-group]
[--retention]
[--set]
[--storage-account]
[--subnet]
[--tags]
[--traffic-analytics {0, 1, f, false, n, no, t, true, y, yes}]
[--user-assigned-identity]
[--vnet]
[--workspace]
示例
使用名称更新存储帐户,让资源组标识存储帐户和网络观察程序
az network watcher flow-log update --location westus --resource-group MyResourceGroup --name MyFlowLog --storage-account accountname
使用 ID 更新存储帐户,以便位置标识网络观察程序
az network watcher flow-log update --location westus --resource-group MyResourceGroup --name MyFlowLog --storage-account accountid
更新另一个资源组上的网络安全组
az network watcher flow-log update --location westus --resource-group MyAnotherResourceGroup --name MyFlowLog --nsg MyNSG
更新另一个资源组上的虚拟网络
az network watcher flow-log update --location westus --resource-group MyAnotherResourceGroup --name MyFlowLog --vnet MyVNet
更新另一个资源组上的子网
az network watcher flow-log update --location westus --resource-group MyAnotherResourceGroup --name MyFlowLog --vnet MyVNet --subnet MySubnet
更新另一个资源组上的网络接口
az network watcher flow-log update --location westus --resource-group MyAnotherResourceGroup --name MyFlowLog --nic MyNIC
更新另一个资源组上的工作区
az network watcher flow-log update --location westus --resource-group MyAnotherResourceGroup --name MyFlowLog --workspace MyAnotherLogAnalyticWorkspace
必需参数
用于标识区域下独占网络观察程序的位置。 每个订阅和区域只能存在一个网络观察程序。
流记录器的名称。
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
通过指定路径和键值对将对象添加到对象列表。 示例:--add property.listProperty <key=value, string or JSON string>
。
属性 | 值 |
---|---|
Parameter group: | Generic Update Arguments |
Enable logging.
属性 | 值 |
---|---|
接受的值: | 0, 1, f, false, n, no, t, true, y, yes |
根据 SrcIP、SrcPort、DstIP、DstPort、协议、加密、方向和操作筛选流日志的更新条件。 如果未指定,将记录所有流日志。
属性 | 值 |
---|---|
Parameter group: | Properties Arguments |
使用“set”或“add”时,保留字符串文本,而不是尝试转换为 JSON。
属性 | 值 |
---|---|
Parameter group: | Generic Update Arguments |
接受的值: | 0, 1, f, false, n, no, t, true, y, yes |
流日志的文件类型。
属性 | 值 |
---|---|
Parameter group: | Format Arguments |
接受的值: | JSON |
FlowLog 资源托管标识支持速记语法、json-file 和 yaml-file。 请尝试“??” 以显示更多内容。
属性 | 值 |
---|---|
Parameter group: | Parameters Arguments |
执行流分析的间隔(以分钟为单位)。 暂时允许的值为 10 和 60。
属性 | 值 |
---|---|
Parameter group: | Traffic Analytics Arguments |
流日志的版本(修订版)。
属性 | 值 |
---|---|
Parameter group: | Format Arguments |
网络接口 (NIC) 资源的名称或 ID。
不等待长时间运行的操作完成。
属性 | 值 |
---|---|
接受的值: | 0, 1, f, false, n, no, t, true, y, yes |
网络安全组的名称或 ID。
从列表中删除属性或元素。 示例: --remove property.list <indexToRemove>
OR --remove propertyToRemove
.
属性 | 值 |
---|---|
Parameter group: | Generic Update Arguments |
资源组的名称。 可以使用 az configure --defaults group=<name>
配置默认组。
保留日志的天数。
通过指定要设置的属性路径和值来更新对象。 示例:--set property1.property2=<value>
。
属性 | 值 |
---|---|
Parameter group: | Generic Update Arguments |
要在其中保存流日志的存储帐户的名称或 ID。 必须位于流日志的同一区域。
子网的名称或 ID。
空格分隔标记:key[=value] [key[=value] ...]。使用“”清除现有标记。 支持速记语法、json-file 和 yaml-file。 请尝试“??” 以显示更多内容。
启用流量分析。 如果提供了 --workspace
,则默认值为 true。
属性 | 值 |
---|---|
Parameter group: | Traffic Analytics Arguments |
接受的值: | 0, 1, f, false, n, no, t, true, y, yes |
ManagedIdentity 资源的名称或 ID。
虚拟网络资源的名称或 ID。
Log Analytics 工作区的名称或 ID。 必须位于流日志的同一区域。
属性 | 值 |
---|---|
Parameter group: | Traffic Analytics Arguments |
全局参数
提高日志记录详细程度以显示所有调试日志。
属性 | 值 |
---|---|
默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
属性 | 值 |
---|---|
默认值: | False |
Output format.
属性 | 值 |
---|---|
默认值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID
配置默认订阅。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
属性 | 值 |
---|---|
默认值: | False |
az network watcher flow-log wait
将 CLI 置于等待状态,直到满足条件。
az network watcher flow-log wait [--created]
[--custom]
[--deleted]
[--exists]
[--ids]
[--interval]
[--name]
[--network-watcher-name]
[--resource-group]
[--subscription]
[--timeout]
[--updated]
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
等待在“Succeeded”中使用“provisioningState”创建。
属性 | 值 |
---|---|
Parameter group: | Wait Condition Arguments |
默认值: | False |
等待条件满足自定义 JMESPath 查询。 例如 provisioningState!='InProgress', instanceView.statuses[?code=='PowerState/running']。
属性 | 值 |
---|---|
Parameter group: | Wait Condition Arguments |
等到删除为止。
属性 | 值 |
---|---|
Parameter group: | Wait Condition Arguments |
默认值: | False |
等待资源存在。
属性 | 值 |
---|---|
Parameter group: | Wait Condition Arguments |
默认值: | False |
一个或多个资源 ID(以空格分隔)。 它应该是包含“Resource Id”参数的所有信息的完整资源 ID。 应提供 --ids 或其他“Resource Id”参数。
属性 | 值 |
---|---|
Parameter group: | Resource Id Arguments |
轮询间隔(以秒为单位)。
属性 | 值 |
---|---|
Parameter group: | Wait Condition Arguments |
默认值: | 30 |
流记录器的名称。
属性 | 值 |
---|---|
Parameter group: | Resource Id Arguments |
网络观察程序的名称。
属性 | 值 |
---|---|
Parameter group: | Resource Id Arguments |
资源组的名称。 可以使用 az configure --defaults group=<name>
配置默认组。
属性 | 值 |
---|---|
Parameter group: | Resource Id Arguments |
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID
配置默认订阅。
属性 | 值 |
---|---|
Parameter group: | Resource Id Arguments |
最大等待(以秒为单位)。
属性 | 值 |
---|---|
Parameter group: | Wait Condition Arguments |
默认值: | 3600 |
等到 provisioningState 更新为“Succeeded”。
属性 | 值 |
---|---|
Parameter group: | Wait Condition Arguments |
默认值: | False |
全局参数
提高日志记录详细程度以显示所有调试日志。
属性 | 值 |
---|---|
默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
属性 | 值 |
---|---|
默认值: | False |
Output format.
属性 | 值 |
---|---|
默认值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
属性 | 值 |
---|---|
默认值: | False |