Azure Data Factory V2 - Add TriggerTime to Kusto query

GouKong 126 Reputation points
2020-11-25T15:51:35.36+00:00

Hi, I want to run Kusto query with a time parameter in ADF so I can debug conveniently. I try many times and want to know how to pass parameter to it although I can write 'let timestring = now()' to make code works. Here is part of my Kusto code.

let timestring = todatetime(@convertFromUtc(pipeline().TriggerTime,'GMT Standard Time','yyyy-MM-dd HH:mm:ss.fff'));
let biasDate = startofday(timestring);
let endDate = datetime_add('day', -2, biasDate);
let startDate = datetime_add('day', -3, biasDate);

and adf will tell me "
Failure happened on 'Source' side. ErrorCode=UserErrorKustoReadFailed,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=Read from Kusto failed with following error: Syntax error: Query could not be parsed: A recognition error occurred.."

Thanks!

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,210 questions
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
10,586 questions
0 comments No comments
{count} votes

Accepted answer
  1. MartinJaffer-MSFT 26,081 Reputation points
    2020-11-25T20:41:23.89+00:00

    Hello @GouKong and welcome to Microsoft Q&A.

    I have seen something similar happen when trying to mix pipeline expression inside a SQL statment/query.

    Could you try:

    let timestring = todatetime(@{convertFromUtc(pipeline().TriggerTime,'GMT Standard Time','yyyy-MM-dd HH:mm:ss.fff')});

    The difference is adding the curly braces { }. The curly braces serve two purposes.

    1. They help Data Factory tell where to start and stop interpreting the content as an expression, as opposed to text to pass to Kusto
    2. They convert the output of the contained expression to a string

    Let us know whether this helps or not. If this solves your issue, please mark as accepted answer. If it does not help you, let us know, and we will look deeper into the issue.

    Thank you for your patience.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

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.