Kusto Stored Function passing Dynamic parameter from C# Azure Function

Zach Moore 6 Reputation points
2022-01-27T16:35:05.27+00:00

Hey,
I'm trying to create an Azure Function that queries the adx database.

In my function would I create an object or list to pass to the Stored Function

Using this in the in the code but getting an error
queryGetTransaction = "declare query_parameters(ID:dynamic); GetTransaction(ID)";

Error:
Text=declare query_parameters(ID:dynamic); GetTransaction(ID)
SemanticErrors='ID' invalid query parameter type (expected 'dynamic)

How would i set that Dynamic parameter with
ClientRequestProperties clientRequestProperties = new ClientRequestProperties();

If I'm not doing this correctly can I pass an object to the stored function and use that for parameters in the where?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,110 questions
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.
531 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Zach Moore 6 Reputation points
    2022-01-31T21:10:03.89+00:00

    I got it working with this...thanks

    string str = JsonConvert.SerializeObject(ID);

    ClientRequestProperties clientRequestProperties = new ClientRequestProperties();
    clientRequestProperties.SetParameter("value", str);

    1 person found this answer helpful.
    0 comments No comments

  2. Vamshi Krishna Kancharla 1 Reputation point
    2022-04-21T23:19:09.8+00:00

    I was able to get it working with the following Approach & Funda.

    ClientRequestProperties.SetParameter() doesn't have 'dynamic' type overload for the Value. So declare Query_Parameters with type as "string" to take the input values.

    And while calling the function inside the query use "todynamic(stringTypedValue)" to convert the string value to Dynamic Object on the fly.

    Pass in the string value as "',' separated values array" parsable by parse_json function => Like ( parse_json('[1, 2, 3, 4]', parse_json('["str1","str2","str3"]'). C# takes in this value as input string while converting it into dynamic type in Kusto on the fly.

    That string is supposed to be converted into the following "dynamic object form" in Kusto => https://learn.microsoft.com/en-us/azure/data-explorer/kusto/query/scalar-data-types/dynamic.

    you can send me an email => vakancharla@microsoft.com, if you need any further information.

    0 comments No comments

  3. Damiano Salezze 0 Reputation points
    2024-08-05T13:55:27.66+00:00

    Please follow original doc https://learn.microsoft.com/en-us/azure/data-explorer/kusto/api/netfx/client-request-properties

    You can pass scalar type (es. dynamic) from Kusto.Data using KQL literal as Parameters in ClientRequestProperties):
    eg.

    declare query_parameters(arrayOfGuids: dynamic, ...)

    ...

    var clientRequestProperties = new ClientRequestProperties()

    clientRequestProperties.SetParameter("arrayOfGuids", "dynamic(['guid1', 'guid2'])")

    Parameters passed must be key-values string but values can be interpreted as common type (es. string, int, long, ..) as well as KQL literal (datetime(..), dynamic(..), ...)

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.