Home / Search/ Language Reference/ Functions/ Scalar Functions/ Dynamic Functions/bag_has_key

bag_has_key

The bag_has_key function checks whether a property bag contains a given key.

Syntax

     bag_has_key( Bag, Key )

Parameters

NameTypeRequiredDescription
BagdynamicYesThe property bag to check.
KeystringYesThe key for which to search.

Returns

Returns true or false, depending on whether the key exists in the bag.

Example

print bag = dynamic({ "foo": 42, "bar": true })
 | extend fooExists = bag_has_key(bag, "foo"),
          blubbExists = bag_has_key(bag, "blubb")

// fooExists: `true`
// blubbExists: `false`