Javascript 在Azure函数中获取设备孪生信息?
所以我有一个azure函数,它从CSV文件中检索数据。我想做的是,在azure函数中检索该信息时,首先检查是否可以获取设备的详细信息。这一切都是在azure函数中的javascript中完成的。因此,该函数是一个异步函数:Javascript 在Azure函数中获取设备孪生信息?,javascript,azure,Javascript,Azure,所以我有一个azure函数,它从CSV文件中检索数据。我想做的是,在azure函数中检索该信息时,首先检查是否可以获取设备的详细信息。这一切都是在azure函数中的javascript中完成的。因此,该函数是一个异步函数: async function getDeviceTwin(){ var devicetwin= await registryManager.GetTwinAsync(deviceID); context.log("device is "+ devicetw
async function getDeviceTwin(){
var devicetwin= await registryManager.GetTwinAsync(deviceID);
context.log("device is "+ devicetwin.deviceId+ "status is " + deviceTwin.status);
}
这个函数显然是这样调用的:
getDeviceTwin()
设备ID位于此处:
IotHubMessages,forEach(newmessage=>{
console.log('message':${newmessage}');
count++;
deviceID=message.deviceID;
当我在azure函数中运行它时,似乎什么也找不到。为什么会出现这种情况您应该更改代码
devicetwin.deviceId
和devicetwin.status
比如:
关于更多细节,你可以在这篇文章中参考我的答案
你的分数表让我震惊。如果你按时接受答案,人们会更乐意帮助你:)如果我的解决方案对你有帮助,你能把我的答案标记为,tks吗~
console.log("device is "+ devicetwin.responseBody.deviceId+ "status is " + devicetwin.responseBody.status);