如何解决如何通过Azure REST API获取IOT Edge模块的运行状态? 不是来自“在设备上获取模块” API调用的connectionState或状态
上下文:
Azure REST - Modules - Get Modules On Device
通过使用此API调用,我可以获得有关模块的connectionState(已连接/已断开连接)和状态(已启用/已禁用)的信息。我们可以通过访问Azure Iot Hub Web门户来检查设备上部署的模块的运行时状态
portal.azure.com -> iot hub -> iot edge section -> select the device you wish to find the details for
问题:
如何通过Azure API获得此RUNTIME STATUS
?(请参考图片)。
解决方法
如果检查edgeAgent的模块对,则如下所示:-
{
"deviceId": "edgeDevice","moduleId": "$edgeAgent","etag": "AAAAAAAAAEA=","deviceEtag": "NDU1OTY3MjA=","status": "enabled","statusUpdateTime": "0001-01-01T00:00:00Z","connectionState": "Disconnected","lastActivityTime": "0001-01-01T00:00:00Z","cloudToDeviceMessageCount": 0,"authenticationType": "sas","x509Thumbprint": {
"primaryThumbprint": null,"secondaryThumbprint": null
},"version": 501,"properties": {
"desired": {
"schemaVersion": "1.0","runtime": {
"type": "docker","settings": {
"minDockerVersion": "v1.25","loggingOptions": "","registryCredentials": {
}
}
},"systemModules": {
"edgeAgent": {
"type": "docker","settings": {
"image": "mcr.microsoft.com/azureiotedge-agent:1.0","createOptions": "{}"
}
},"edgeHub": {
"type": "docker","status": "running","restartPolicy": "always","settings": {
"image": "mcr.microsoft.com/azureiotedge-hub:1.0","createOptions": "{\"HostConfig\":{\"PortBindings\":{\"5671/tcp\":[{\"HostPort\":\"5671\"}],\"8883/tcp\":[{\"HostPort\":\"8883\"}],\"443/tcp\":[{\"HostPort\":\"443\"}]}}}"
}
}
},"modules": {
"CustomModuleName": {
"version": "1.0","type": "docker","settings": {
"image": "iotregdev300.azurecr.io/customModuleName:0.0.2-amd64","createOptions": "{\"HostConfig\":{\"PortBindings\":{\"8080/tcp\":[{\"HostPort\":\"8080\"}]}}}"
}
}
}
},"reported": {
"schemaVersion": "1.0","version": {
"version": "1.0.9.4","build": "32971639","commit": "12d55e582cc7ce95c8abfe11eddfbbc938ed6001"
},"lastDesiredStatus": {
"code": 200,"description": ""
},"runtime": {
"platform": {
"os": "linux","architecture": "x86_64","version": "1.0.9.4"
},"exitCode": 0,"statusDescription": "running","lastStartTimeUtc": "2020-09-09T07:34:34.4585643Z","lastExitTimeUtc": "2020-09-09T07:34:26.9869915Z","runtimeStatus": "running","imagePullPolicy": "on-create","imageHash": "sha256:1a2fffc3c74a2b2510a3149bb2295b68a553e4c9aca90698879902f36fd6d163","env": {},"lastStartTimeUtc": "2020-09-09T07:34:50.8012461Z","lastExitTimeUtc": "2020-09-09T07:34:26.9845717Z","restartCount": 0,"lastRestartTimeUtc": "2020-09-09T07:34:26.9845717Z","imageHash": "sha256:f531eb6c23f347c37ea8c90204e9cb12024aec77d8b2e68e93b14c38ec066520","lastDesiredVersion": 64,"modules": {
"CustomModuleName": {
"exitCode": 0,"lastStartTimeUtc": "2020-09-09T07:34:49.3923079Z","lastExitTimeUtc": "2020-09-09T07:34:26.9606688Z","lastRestartTimeUtc": "2020-09-09T07:34:26.9606688Z","version": "1.0","settings": {
"image": "iotregdev300.azurecr.io/custommodulename:0.0.2-amd64","imageHash": "sha256:e728d4b8804d2114beab7c1903f706d8152e404be3f5601ee5e7371e8ac32ecf","createOptions": "{\"HostConfig\":{\"PortBindings\":{\"8080/tcp\":[{\"HostPort\":\"8080\"}]}}}"
},"env": {}
}
}
}
}
}
在上面的json中,CustomModuleName
是自定义模块,它具有名为runtimeStatus: "running"
的字段。 edgeHub和edgeAgent模块中也存在相同的字段。因此,您只需要通过REST API或Azure Device / Service sdk来获取edgeAgentTwin。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。