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

ADX 156 Reputation points
2021-10-27T09:13:49.09+00:00

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
Azure Data Explorer
An Azure data analytics service for real-time analysis on large volumes of data streaming from sources including applications, websites, and internet of things devices.
479 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. HimanshuSinha-msft 19,376 Reputation points Microsoft Employee
    2021-10-28T21:03:36.32+00:00

    Hello @ADX ,
    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