Forum Discussion

Benjamin Girardeau's avatar
Jun 26, 2018

Creating a stored function with parameters

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.

 
  • 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.

    • Vino55's avatar
      Vino55
      Icon for Microsoft rankMicrosoft

      Hi Evgeny Ternovsky,

       

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

       

      Thanks.

    • mark_nettle's avatar
      mark_nettle
      Copper Contributor
      Making this possible would an be incredibly useful addition to Log Analytics

Resources