Skip to content

Commit d972674

Browse files
authored
Merge pull request #5692 from MicrosoftDocs/poliveria-custom-functions-11202025
Update custom functions doc and add new images
2 parents ac57cc4 + f6ca37a commit d972674

File tree

5 files changed

+46
-21
lines changed

5 files changed

+46
-21
lines changed

defender-xdr/advanced-hunting-custom-functions.md

Lines changed: 45 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,39 +36,63 @@ ms.date: 03/28/2025
3636
> Some information relates to prereleased product which may be substantially modified before it's commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
3737
3838
## Types of functions
39-
A function is a type of query in advanced hunting that can be used in other queries as if it's a command. You can create your own custom functions so you can reuse any query logic when you hunt in your environment.
39+
A function is a type of query in advanced hunting that you can use in other queries as if it's a command. You can create your own custom functions so you can reuse any query logic when you hunt in your environment.
4040

4141
There are three different types of functions in advanced hunting:
4242

4343
![Function types](/defender/media/advanced-hunting-custom-fxns/function-types.png)
4444

45-
- **Built-in functions** – Prebuilt functions included with Microsoft Defender XDR advanced hunting. These are available in all advanced hunting instances and can't be modified.
46-
- **Shared functions** – Custom functions created by users, which are available for all users in a specific tenant and can be modified and controlled by users.
47-
- **My functions** – Custom functions created by a user, which can be viewed and modified only by the user who created it.
45+
- **Built-in functions** – Prebuilt functions included with Microsoft Defender XDR advanced hunting. These functions are available in all advanced hunting instances and can't be modified.
46+
- **Shared functions** – Custom functions that users create. All users in a specific tenant can access these functions. Users can modify and control these functions.
47+
- **My functions** – Custom functions that a user creates. Only the user who created these functions can view and modify them.
4848

4949
## Write your own custom function
5050

51-
To create a function from the current query in the editor, select **Save** and then **Save as function**.
51+
To create a function from the current query in the editor:
5252

53-
![Save as function](/defender/media/advanced-hunting-custom-fxns/save-as-function.png)
53+
1. Select **Save** and then **Save as function**.
54+
![Save as function](/defender/media/advanced-hunting-custom-fxns/save-as-function.png)
5455

55-
Next, provide the following information:
56+
1. In the **Save as function** flyout panel, provide the following information:
5657

57-
- **Name** - Name of the function. Can contain only numbers, English letters, and underscores. To avoid accidentally using Kusto keywords, begin or end function names with an underscore or begin with a capital letter.
58-
- **Location** - The folder in which you would like to save the function, either shared or private.
59-
- **Description** - A description that can help other users understand the purpose of the function and how it works.
60-
- **Parameters** - Add a parameter for each variable in the function that requires a value when it's used.
61-
Add parameters to a function so that you can provide the arguments or values for certain variables when calling the function. This allows the same function to be used in different queries, each allowing for different values for the parameters. Parameters are defined by the following properties:
58+
- **Name** - Name of the function. Can contain only numbers, English letters, and underscores. To avoid accidentally using Kusto keywords, begin or end function names with an underscore or begin with a capital letter.
59+
- **Location** - The folder in which you want to save the function, either shared or private.
60+
- **Description** - A description that helps other users understand the purpose of the function and how it works.
61+
- **Parameters** - Add a parameter for each variable in the function that requires a value when it's used. For more information, see [Add parameters to your custom function](#add-parameters-to-your-custom-function).
62+
63+
![Save as function dialog box](/defender/media/advanced-hunting-custom-fxns/save-as-function-dialog-box.png)
64+
65+
1. Select **Save**.
66+
67+
### Add parameters to your custom function
68+
69+
You can add parameters to a function so that you can provide the arguments or values for certain variables when calling the function. This feature allows the same function to be used in different queries, each with different values for the parameters.
70+
71+
To add parameters when saving your custom function, select **Add parameter**, then enter the following properties:
6272
- **Type** - Data type for the value
6373
- **Name** - The name that must be used in the query to replace the parameter value
64-
- **Default value** - Value to be used for the parameter if a value isn't provided
74+
- **Default value** - Value to use for the parameter if you don't provide a value
6575

66-
Parameters are listed in the order they were created, with parameters that have no default value listed above those that have a default value.
76+
Parameters are listed in the order you create them, with parameters that have no default value listed before those that have a default value.
6777

68-
![Save as function dialog box](/defender/media/advanced-hunting-custom-fxns/save-as-function-dialog-box.png)
78+
### Create custom functions with tabular parameters
6979

80+
Create custom functions that use tabular parameters. With tabular parameters, you can pass entire tables as inputs. This approach lets you build more modular, reusable, and expressive logic across your hunting queries. This capability is especially useful for complex hunting scenarios that require structured data inputs.
81+
82+
To create tabular parameters for your custom function:
83+
1. Select **Add parameter** and then choose **table** as its **Type**.
84+
1. Enter a **Name** and **Default value** for the table.
85+
1. Map each column that your query references to the table. Select **Add column**, then enter the column's properties.
86+
87+
![Table parameter in custom functions](/defender/media/advanced-hunting-custom-fxns/save-as-function-table.png)
88+
89+
> [!NOTE]
90+
>- You can save a function with more than one table.
91+
>- If your query doesn't reference any columns in the table parameter, you can still save and run the function without mapping any columns.
92+
>- You can set tabular and scalar parameters in the same function.
93+
7094
## Use a custom function
71-
Use a function in a query by typing its name along with values for any parameter just as you would type in a command. The output of the function can either be returned as results or piped to another command.
95+
Use a function in a query by typing its name along with values for any parameter, just as you would type in a command. The output of the function can either be returned as results or piped to another command.
7296

7397
Add a function to the current query by double-clicking on its name or selecting the three dots to the right of the function and selecting **Open in query editor**.
7498

@@ -77,27 +101,27 @@ If a query requires arguments, provide them using the following syntax: *functio
77101
![Open in query editor](/defender/media/advanced-hunting-custom-fxns/open-in-query-editor.png)
78102

79103
> [!NOTE]
80-
> Functions can't be used inside another function.
104+
> You can't use functions inside another function.
81105
82106
## Work with function codes
83-
You can view the code of a function either to gain insight into how it works or to modify its code. Select the three dots to the right of the function and select **Load function code** to open a new tab with the function code.
107+
You can view the code of a function to understand how it works or to modify its code. Select the three dots to the right of the function and select **Load function code** to open a new tab with the function code.
84108

85109
![Load function code](/defender/media/advanced-hunting-custom-fxns/load-function-code.png)
86110

87111
## Edit a custom function
88112

89-
Edit the properties of a function by selecting the three dots to the right of the function and selecting **Edit details**. Make any modifications that you want to the properties and parameters of the function then select **Save**.
113+
Edit the properties of a function by selecting the three dots to the right of the function and selecting **Edit details**. Make any modifications that you want to the properties and parameters of the function, then select **Save**.
90114

91115
![Edit function code](/defender/media/advanced-hunting-custom-fxns/edit-function.png)
92116

93-
If the function code is already loaded to the editor, you can also select **Save** to apply any changes to the code or properties of the function.
117+
If the function code is already loaded in the editor, you can also select **Save** to apply any changes to the code or properties of the function.
94118

95119
> [!NOTE]
96120
> Once a function is in use in a saved query or a detection rule, you can't edit the function to expand its scope. For example, if you saved a function that queries identity tables, and this function is used in a detection rule, you can't edit the function to include a device table after the fact. To do that, you can save a new function. Product scoping can be narrowed for the same function but not extended.
97121
98122
## Delete a custom function
99123

100-
You can delete functions from **My functions** and functions you created in **Shared functions**. You cannot delete functions that you have not created, unless you have security data manage permissions.
124+
You can delete functions from **My functions** and functions you created in **Shared functions**. You can't delete functions that you didn't create, unless you have security data manage permissions.
101125

102126
To delete a function, select the three dots to the right of the function and select **Delete**.
103127

defender-xdr/whats-new.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ You can also get product updates and important notifications through the [messag
3434

3535
## December 2025
3636
- (GA) The [hunting graph](advanced-hunting-graph.md) in advanced hunting is now generally available. It also now has two new predefined threat scenarios that you can use to render your hunts as interactive graphs.
37+
- Advanced hunting now supports custom functions that use tabular parameters. With tabular parameters, you can pass entire tables as inputs. This approach lets you build more modular, reusable, and expressive logic across your hunting queries. [Learn more](advanced-hunting-custom-functions.md#create-custom-functions-with-tabular-parameters)
3738

3839
## November 2025
3940
- Microsoft Sentinel customers using the Defender portal, or the Azure portal with the Microsoft Sentinel Defender XDR data connector, now also benefit from Microsoft Threat Intelligence alerts that highlight activity from nation-state actors, major ransomware campaigns, and fraudulent operations. To view these alert types, you must have the **Security Administrator** or **Global Administrator** role. The **Service Source**, **Detection Source**, and **Product Name** values for these alerts are listed as *Microsoft Threat Intelligence*. For more information, see [Incidents and alerts in the Microsoft Defender portal](incidents-overview.md).
99.8 KB
Loading
25 KB
Loading
70.4 KB
Loading

0 commit comments

Comments
 (0)