0

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?

CHEEKATLAPRADEEP
  • 12,191
  • 1
  • 19
  • 42
Sam
  • 1,252
  • 5
  • 20
  • 43
  • What about the DemoOutput? Is it working? For test purpose, add the output for Blob storage and replace in your query c2d to DemoOutputBlob. – Roman Kiss Dec 01 '17 at 09:06
  • The DemoOutput is output to SQL. It is working. – Sam Dec 01 '17 at 09:48

1 Answers1

0

Try the following query for test purpose, only. Note, that I took out your DemoML function and the output is for Blob storage. You should see outputs in the AF and Blob storage:

WITH subquery as (
     SELECT 
       System.Timestamp as time,
       temperature, 
       humidity,
       EventProcessedUtcTime,
       IoTHub.ConnectionDeviceId as deviceId,
       IoTHub.MessageId as messageId
     FROM
       DemoInput Timestamp by time
    )

SELECT
    messageId as messageId,
    deviceId as deviceId,
    temperature as temperature,
    humidity as humidity,
    EventProcessedUtcTime as EventProcessedUtcTime
INTO
    DemoOutputBlob
FROM
    subquery


SELECT
    *
INTO
    c2d
FROM
    subquery
Roman Kiss
  • 7,925
  • 1
  • 8
  • 21
  • Hi, I asked the question in another post as I realised the problem is the Azure function app. Can you help me to take a look? https://stackoverflow.com/questions/47604272/c-sharp-jsonconvert-deserializeanonymoustype-failed – Sam Dec 02 '17 at 03:31