I have created a Azure Function to return the result to device when the device send data to Azure IoT hub. I follow the tutorial to send the output to SQL and Azure function. Here is my ASA query.
WITH subquery as (
    SELECT 
    messageId,
    deviceId,
    temperature, 
    humidity,
    EventProcessedUtcTime,
    DemoML(temperature, humidity) as result1
    from DemoInput
    )
SELECT
    messageId as messageId,
    deviceId as deviceId,
    temperature as temperature,
    humidity as humidity,
    EventProcessedUtcTime as EventProcessedUtcTime,
    result1.[Scored Labels] as result,
    result1.[Scored Probabilities] as resultProbability
INTO
    [DemoOutput]
FROM
    [subquery]
SELECT
    *
INTO
    [c2d]
FROM
    [subquery] 
I do not know why it would not trigger the Azure function. But when I change the last line from [subquery] to [DemoInput] then it will work. Why is this happen?