你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
toguid()
Applies to: ✅ Microsoft Fabric ✅ Azure Data Explorer ✅ Azure Monitor ✅ Microsoft 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 |