Search code examples
azure-data-explorerkqldata-ingestionkusto-explorer

Azure Data Explorer: How to ingest row into table from within a stored function


In Azure Data Explorer (Kusto) how do I ingest a row into a table from within a stored function?

I can ingest a row into a table using the following:

.ingest inline into table TestTable <|
"valueForColumn1", "valueForColumn2"

I can create a stored function:

.create-or-alter function with (docstring="TestTable" folder="path\\folder") fn_TestTable(col1:string, col2:string) 
{
   TestTable | take 5
}

But when I try to change the stored function to use the .ingest command I get a syntax error for the period (Token .)

The following command displays a syntax error:

.create-or-alter function with (docstring="TestTable" folder="path\\folder") fn_TestTable(col1:string, col2:string) 
{
   .ingest inline into table TestTable <|
   "valueForColumn1", "valueForColumn2"
}

Is this not possible or am I making a mistake?

For context, our team would like to expose the ability to write to TestTable to other teams, but instead of giving other teams access to TestTable to write directly to the table we would like to perform some validation in the stored function and have the other teams write to TestTable through the stored function. Is this standard or is there a more preferred way?


Solution

  • That isn't supported. You can find the full explanation in the following post: Not able to have commands in User-Defined functions in Kusto