我从 20-30 个 API 获取数据并将数据推送到事件中心,我需要以不同的方式在 Azure 流分析中处理来自事件中心的数据,那么如何使用 azure 流识别来自不同 API 或源的数据分析。我在我的代码中发送如下数据:
module.exports = async function (context, myTimer) {
const { EventHubClient, EventData, EventPosition, OnMessage, OnError, MessagingError } = require("@azure/event-hubs");
const connectionString = 'Endpoint=Connection string'
var axios = require('axios')
context.log('ssss')
const client = EventHubClient.createFromConnectionString(connectionString);
context.log('sssaaa')
var response = await axios.get('https://nseindia.com/live_market/dynaContent/live_watch/stock_watch/nifty500StockWatch.json')
// var sendBatchData = [
// {body:{response['data']['data']}}
// ]
const datas = [
{ body: { "message": "Hello World 1" }, applicationProperties: { id: 1 }, partitionKey: "pk786" },
{ body: { "message": "Hello World 2" } },
{ body: { "message": "Hello World 3" } }
];
// context.log(sendBatchData)
await client.sendBatch(datas)
context.log('message sent')
// async function main():Promise<void> {
// }
// var timeStamp = new Date().toISOString();
// if (myTimer.IsPastDue)
// {
// context.log('JavaScript is running late!');
// }
// context.log('JavaScript timer trigger function ran!', timeStamp);
};
但是在天蓝色的字符串分析网站上,我得到的数据如下:
{
"message": "Hello World 3",
"EventProcessedUtcTime": "2019-09-23T09:52:09.1421367Z",
"PartitionId": 0,
"EventEnqueuedUtcTime": "2019-09-23T09:51:38.8270000Z"
},
{
"message": "Hello World 1",
"EventProcessedUtcTime": "2019-09-23T09:52:08.6420937Z",
"PartitionId": 0,
"EventEnqueuedUtcTime": "2019-09-23T09:51:38.8270000Z"
},
{
"message": "Hello World 2",
"EventProcessedUtcTime": "2019-09-23T09:52:09.1421367Z",
"PartitionId": 0,
"EventEnqueuedUtcTime": "2019-09-23T09:51:38.8270000Z"
}
]
我没有看到任何重新电镀到我的分区键的东西。我的目标是,当我从多个 Api 源发送数据时,如何区分 Azure 流分析
提前致谢