Creating a stored function with parameters

Microsoft

Hi,

 

I would like to create a stored function that has input parameters. Is there a way I can do this?

 

Right now I have:

 

// --- Start of stored function ------

let DiffUsers = (vmid: string, ts1: datetime, ts2: datetime)
 {
...
};

// --- End of stored function ------

 

But when trying to call DiffUsers(vmid, ts1, ts2) outside of the stored function I get an error.

 
3 Replies

You can use a let statement as in your example to serve the same purpose as a SProc. Today, however, this is only possible at query time; you cannot unfortunately save these as a "function" the same way that you can with views. It is something on our backlog, but will take a while to properly implement. For more details on the query-time options available, check out the article on UDFs.

Making this possible would an be incredibly useful addition to Log Analytics

Hi @Evgeny Ternovsky,

 

Any idea when this feature will be lightened up?
we are looking forward to use saved function with parameters.

 

Thanks.