我已将多个设备连接到 Azure 流分析,这些设备将发送各种数据。 (温度、光照、湿度等)
我不确定如何读取数据 Azure 资源并将其显示在我在 Azure 上发布的 Web 应用程序上。例如读取device_name、设备的数据。
我需要的可能是一个示例代码,它从 Azure 读取一些数据,然后将其显示在简单的“h1”或“p”标签上。
PS:我看过很多教如何将 Web 应用程序发布到 Azure 的教程。但几乎没有任何教程专门教授如何从 Azure 资源读取和获取数据。
最佳答案
您可以使用Azure SDK for Node.js管理 Azure 资源。
这是检索有关现有事件中心的信息的示例。这是 Azure Node SDK reference .
const msRestAzure = require('ms-rest-azure');
const EventHubManagement = require('azure-arm-eventhub');
const resourceGroupName = 'testRG';
const namespaceName = 'testNS';
const eventHubName = 'testEH';
const subscriptionId = 'your-subscription-id';
msRestAzure
.interactiveLogin()
.then(credentials => {
const client = new EventHubManagement(credentials, subscriptionId);
return client.eventHubs.get(resourceGroupName, namespaceName, eventHubName);
})
.then(zones => console.dir(zones, { depth: null, colors: true }))
.catch(err => console.log(err));
关于node.js - 创建一个从 AZURE 读取数据的 Nodejs Web 应用。 (流分析或事件中心或日志分析),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55113239/