Use the base64_encode_fromarray function to convert a sequence of bytes into a Base64-encoded string. This function is useful when you need to transform binary data into a textual representation for safe storage, logging, or transmission—especially over protocols that require plain-text formats.

You can apply this function when working with IP addresses, file contents, or any byte array that needs to be encoded for use in logs or APIs. It accepts a byte array and returns the Base64-encoded string representation of that array.

For users of other query languages

If you come from other query languages, this section explains how to adjust your existing queries to achieve the same results in APL.

Usage

Syntax

base64_encode_fromarray(array)

Parameters

NameTypeRequiredDescription
arraydynamic✔️A dynamic array of integers between 0 and 255 representing byte values.

Returns

If successful, returns a string representing the Base64-encoded version of the input byte array. If the input is not a valid array of bytes, the result is an empty string.

Example

Use this function to encode request metadata for logging or comparison with external systems that require Base64-encoded fields.

Query

['sample-http-logs']
| extend ip_bytes = dynamic([192, 168, 0, 1])
| extend encoded_ip = base64_encode_fromarray(ip_bytes)
| project _time, id, method, uri, encoded_ip

Run in Playground

Output

_timeidmethoduriencoded_ip
2025-06-25T08:00:00Zuser123GET/api/datawKgAAQ==

Encodes a hardcoded byte representation of an IP address into Base64 for easy string-based comparison or logging.

  • array_concat: Concatenates arrays of bytes or values. Use this when building byte arrays for Base64 encoding.
  • base64_decode_toarray: Decode a Base64-encoded string into an array of bytes. Use this when decoding data received from external sources.
  • format_ipv4_mask: Formats a raw IPv4 address with an optional prefix into CIDR notation. Use when dealing with IP-to-string transformations.
  • parse_ipv4: Parses a string representation of an IP address into its numeric form. Use this before encoding or masking IP addresses.