你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
bag_has_key()
Applies to: ✅ Microsoft Fabric ✅ Azure Data Explorer ✅ Azure Monitor ✅ Microsoft Sentinel
Checks whether a dynamic property bag object contains a given key.
Syntax
bag_has_key(
bag,
key)
Learn more about syntax conventions.
Parameters
Name | Type | Required | Description |
---|---|---|---|
bag | dynamic |
✔️ | The property bag to search. |
key | string |
✔️ | The key for which to search. Search for a nested key using the JSONPath notation. Array indexing isn't supported. |
Returns
True or false depending on if the key exists in the bag.
Examples
datatable(input: dynamic)
[
dynamic({'key1' : 123, 'key2': 'abc'}),
dynamic({'key1' : 123, 'key3': 'abc'}),
]
| extend result = bag_has_key(input, 'key2')
Output
input | result |
---|---|
{ "key1": 123, "key2": "abc" } |
true |
{ "key1": 123, "key3": "abc" } |
false |
Search using a JSONPath key
datatable(input: dynamic)
[
dynamic({'key1': 123, 'key2': {'prop1' : 'abc', 'prop2': 'xyz'}, 'key3': [100, 200]}),
]
| extend result = bag_has_key(input, '$.key2.prop1')
Output
input | result |
---|---|
{ "key1": 123, "key2": { "prop1": "abc", "prop2": "xyz" }, "key3": [ 100, 200 ] } |
true |