You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure Stream Analytics查询结果转JSON传入Azure Function方法问询

Convert Stream Analytics Query Results to JSON for Azure Function

Got it, let's get your Stream Analytics results into JSON format before sending them to your Azure Function. Here are two reliable ways to do this:

1. Adjust Output Serialization Settings (Simplest Approach)

If you just need each record serialized as a standard JSON object, you don't even need to modify your query—just tweak the output configuration for your Azure Function target:

  • Go to your Azure Stream Analytics job, navigate to the Outputs tab.
  • Select your fsSMSemailAPP output (the Azure Function).
  • In the serialization settings:
    • Set Serialization format to JSON.
    • Choose between Line separated (each record is a standalone JSON object on its own line) or Array (all records wrapped in a JSON array) based on what your Azure Function expects.
  • Save the settings, restart your Stream Analytics job, and your results will now be sent as JSON directly to the function.

2. Manually Construct Custom JSON in Your Query

If you need full control over the JSON structure (like custom field names or nested objects), you can build the JSON string directly in your query using Stream Analytics' built-in functions:

SELECT 
    CONCAT(
        '{',
        '"Asset_Key": "', STRING_ESCAPE(i1.Asset_Key, 'json'), '",',
        '"Online": 0,',
        '"Last_Updated_UTC": "', STRING_ESCAPE(i1.eventenqueuedutctime, 'json'), '",',
        '"Latest_Record_Date": "', STRING_ESCAPE(i1.eventenqueuedutctime, 'json'), '"',
        '}'
    ) AS JsonPayload
INTO fsSMSemailAPP
FROM YourInputStream i1 -- Replace with your actual input alias
  • STRING_ESCAPE ensures any special characters (like quotes or backslashes) in your data are properly escaped to avoid invalid JSON.
  • The CONCAT function stitches together the JSON structure piece by piece.
  • Your Azure Function will receive the JsonPayload field containing the complete JSON string for each record.

Either of these methods should solve your problem—start with the first one if you don't need custom JSON, since it's the quickest setup.

内容的提问来源于stack exchange,提问作者RSH

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 10:18:30