无法使用Azure流分析处理数据吗?

时间:2019-09-24 07:19:14

标签: node.js azure-functions azure-eventhub azure-stream-analytics

我正在使用以下代码从azure函数向事件中心发送数据。

module.exports = async function (context, myTimer) {
    const {  EventHubClient, EventData, EventPosition, OnMessage, OnError, MessagingError } = require("@azure/event-hubs");
    const connectionString = "Endpoint=connection string"
    const eventHubsName = "eventhub_2"
    var axios = require('axios')

    const client = EventHubClient.createFromConnectionString(connectionString, eventHubsName);
    context.log('sssaaa')
    var response = await axios.get('https://nseindia.com/live_market/dynaContent/live_watch/stock_watch/nifty500StockWatch.json')
    await client.send(response['data']['data'])
    context.log('message sent')

};

我可以发送数据,但是当我使用Azure流分析处理数据时,我正在关注

error:
No events found for 'NSEStockInput'.
Start time: Tuesday, September 24, 2019, 12:30:18 PM
End time: Tuesday, September 24, 2019, 12:33:18 PM
Last time arrival: Tuesday, September 24, 2019, 12:33:18 PM
Diagnostics: Source '<unknown_location>' had 1 occurrences of kind 'InputDeserializerError.InvalidData' between processing times '2019-09-24T07:03:22.9492042Z' and '2019-09-24T07:03:22.9492042Z'. Json input stream should either be an array of objects or line separated objects. Found token type: Null

'InputDeserializerError.InvalidData'意味着在这里它对数据进行序列化,因此我需要以反序列化的方式发送数据,但是client.send或client.batch只能接受JSON对象类型的数据。 这是发送到事件中心的示例JSON。

[ { symbol: 'ALLCARGO',
    open: '106.90',
    high: '114.90',
    low: '106.70',
    ltP: '109.75',
    ptsC: '8.60',
    per: '8.50',
    trdVol: '8.20',
    trdVolM: '0.82',
    ntP: '9.03',
    mVal: '0.09',
    wkhi: '124.45',
    wklo: '87.15',
    wkhicm_adj: '357.70',
    wklocm_adj: '102.00',
    xDt: '31-DEC-2999',
    cAct: '-',
    previousClose: '101.15',
    dayEndClose: '-',
    iislPtsChange: '8.60',
    iislPercChange: '8.50',
    yPC: '3.98',
    mPC: '19.55' },
  { symbol: 'IDBI',
    open: '30.80',
    high: '33.80',
    low: '30.40',
    ltP: '33.25',
    ptsC: '2.30',
    per: '7.43',
    trdVol: '132.04',
    trdVolM: '13.20',
    ntP: '43.01',
    mVal: '0.43',
    wkhi: '65.75',
    wklo: '23.65',
    wkhicm_adj: '116.40',
    wklocm_adj: '52.90',
    xDt: '09-AUG-2019',
    cAct: 'ANNUAL GENERAL MEETING',
    previousClose: '30.95',
    dayEndClose: '-',
    iislPtsChange: '2.30',
    iislPercChange: '7.43',
    yPC: '-36.91',
    mPC: '18.54' }]

error message screen shot

stream analytics input

当我将以下代码与事件中心一起使用时,在azure函数中进行绑定时,它工作正常 module.exports =异步函数(上下文,myTimer){     var axios = require('axios')     var response = await axios.get('https://nseindia.com/live_market/dynaContent/live_watch/stock_watch/nifty500StockWatch.json')     // var sendBatchData = {body:response ['data'] ['data'],partitionKey:“ pk12345”}     // context.log(response ['data'] ['data'])     //样本= [{'name':'saran'},{'name':'jeeva'}]     返回JSON.stringify(response ['data'] ['data'])

};

0 个答案:

没有答案