Redigera

Dela via


toguid()

Applies to: ✅ Microsoft FabricAzure Data ExplorerAzure MonitorMicrosoft Sentinel

Converts a string to a guid scalar.

Note

When possible, use guid literals instead.

Syntax

toguid(value)

Learn more about syntax conventions.

Parameters

Name Type Required Description
value scalar ✔️ The value to convert to guid.

Returns

The conversion process takes the first 32 characters of the input, ignoring properly located hyphens, validates that the characters are between 0-9 or a-f, and then converts the string into a guid scalar. The rest of the string is ignored.

If the conversion is successful, the result will be a guid scalar. Otherwise, the result will be null.

Example

datatable(str: string)
[
    "0123456789abcdef0123456789abcdef",
    "0123456789ab-cdef-0123-456789abcdef",
    "a string that is not a guid"
]
| extend guid = toguid(str)

Output

str guid
0123456789abcdef0123456789abcdef 01234567-89ab-cdef-0123-456789abcdef
0123456789ab-cdef-0123-456789abcdef 01234567-89ab-cdef-0123-456789abcdef
a string that isn't a guid