I have created a realtime solution using Azure services. It works based on the following architecture. NSE(National Stock Exchanges) -> AzureFunction -> EventHub ->Azure Stream Analytics -> Power BI. In the Azure Function, I wrote the following code.
module.exports = async function (context, myTimer) {
var API = require('indian-stock-exchange')
var NSEAPI = API.NSE;
let promise = new Promise((resolve,reject)=>{
NSEAPI.getGainers()
.then(function (response) {
context.log(response['data']); //return the api data
resolve(response['data'])
});
});
let result = await promise;
result = JSON.stringify(result['data'])
return result
};
I'm using the library here and that calls through the HTTP request but for the streaming, this not a right way, can you guys share any suggestion on my code or any changes on architecture workflow.
Thanks in advance.