Editar

Partilhar via


format_ipv4_mask()

Applies to: ✅ Microsoft FabricAzure Data ExplorerAzure MonitorMicrosoft Sentinel

Parses the input with a netmask and returns a string representing the IPv4 address in CIDR notation.

Syntax

format_ipv4_mask(ip [, prefix])

Learn more about syntax conventions.

Parameters

Name Type Required Description
ip string ✔️ The IPv4 address as CIDR notation. The format may be a string or number representation in big-endian order.
prefix int An integer from 0 to 32 representing the number of most-significant bits that are taken into account. If unspecified, all 32 bit-masks are used.

Returns

If conversion is successful, the result will be a string representing IPv4 address as CIDR notation. If conversion isn't successful, the result will be an empty string.

Examples

datatable(address:string, mask:long)
[
 '192.168.1.1', 24,          
 '192.168.1.1', 32,          
 '192.168.1.1/24', 32,       
 '192.168.1.1/24', long(-1), 
]
| extend result = format_ipv4(address, mask), 
         result_mask = format_ipv4_mask(address, mask)

Output

address mask result result_mask
192.168.1.1 24 192.168.1.0 192.168.1.0/24
192.168.1.1 32 192.168.1.1 192.168.1.1/32
192.168.1.1/24 32 192.168.1.0 192.168.1.0/24
192.168.1.1/24 -1