question

SQL-6436 avatar image
0 Votes"
SQL-6436 asked SQL-6436 commented

Azure Data Explorer Function to insert the data into Azure Data Explorer table

Hi,

I have a requirement to insert the data into azure data explorer table that the data received from the input parameters.

My Table structure:

Table Name: AlarmReview
Table Columns: AlarmId:int,Reviewed:int,CreatedDate:datetime

I was able to insert the data from sample json data

for example

.ingest inline into table AlarmReview with (format="multijson", ingestionMappingReference="AlarmReviewMapping")
<|{
"AlarmTxId":1,
"Reviewed":1,
"CreatedDate":"2021-10-20"
}

Can we insert the same json data from the azure data explorer function parameters

.create-or-alter function fnAlarmReview(AlarmId:int,Reviewed:int,CreatedDate:datetime)
{
.ingest inline into table AlarmReview with (format="multijson", ingestionMappingReference="AlarmReviewMapping")
<|
AlarmTxId==AlarmId,
Reviewed==Reviewed,
CreatedDate==CreatedDate
}

i am unable to create the function.

Is the function is right first of all.

Please advise on this.

Thanks

azure-data-explorer
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

HimanshuSinha-MSFT avatar image
0 Votes"
HimanshuSinha-MSFT answered SQL-6436 commented

Hello @SQL-6436 ,
Thanks for the ask and using Microsoft Q&A platform .
Unfortunately its not possible. Admin commands can’t be set in a function.

You can, however, declare a function which generates this data :

.create function myfunc(a:long, b:long, c:long)
{
print a, b, c
}

And then use in the context of a .set-or-append command :

.set-or-append TargetTable <| myfunc(1,2,3)


Please do let me know how it goes .
Thanks
Himanshu


  • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how

  • Want a reminder to come back and check responses? Here is how to subscribe to a notification

  • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators



· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi Himanshu,

I can't create any function/Materialized view on top of ".set-or-append TargetTable <| myfunc(1,2,3)" this command. I want to automate this process when user enters the data in the function that should be inserted into the table automatically and i can't schedule any job to execute the ".set-or-append TargetTable <| myfunc(1,2,3)".

Appreciate your inputs.

Thanks




0 Votes 0 ·