答案 0 :(得分:1)
您使用Microsoft Azure设备客户端SDK /软件包并通过以下方式对其进行攻击:
var registryManager = RegistryManager.CreateFromConnectionString(connString); //the connection string for your IOT Hub
var moduleTwins= new List<Twin>();
//var query = registryManager.CreateQuery($"SELECT * FROM devices", 100);
var query = registryManager.CreateQuery("SELECT * FROM devices.modules WHERE deviceId='MyEdgeDevice'",100);
while (query.HasMoreResults) {
var page = await query.GetNextAsTwinAsync();
moduleTwins.AddRange(page);
}
// this gets rid of all that version/metadata noise in a module/device twin
foreach (var module in moduleTwins) {
module.Properties.Reported.ClearMetadata();
module.Properties.Desired.ClearMetadata();
}
现在moduleTwins
现在是Twin对象的可枚举列表(它是模块/设备twin的直接表示)。除了有趣之外,还有$ edgeAgent和$ edgeHub孪生子-包含一切-并且在edgeAgent的modules
列表中,您会看到更多这些信息在$ edgeAgent的properties.desired.modules
区域中找到的每个模块(图像,创建选项,重启策略等)
"modules": {
"MyNeatModule": {
"type": "docker",
"settings": {
"image": "myAzureContainerRegistry.io/myneatmodule:amd64.debug",
"createOptions": "{}"
},
"status": "running",
"restartPolicy": "always",
"version": "1.0"
},
,您要查找的所有内容都在$ edgeAgent的properties.reported
区域中:
"modules": {
"SuperNeatAwesomeModule": {
"exitCode": 0,
"statusDescription": "running",
"lastStartTimeUtc": "2018-11-01T18:39:09.8814806Z",
"lastExitTimeUtc": "2018-11-01T18:05:40.8350456Z",
"restartCount": 0,
"lastRestartTimeUtc": "2018-11-01T18:05:40.8350456Z",
"runtimeStatus": "running",
"version": "1.0",
"status": "running",
"restartPolicy": "always",
"type": "docker",
"settings": {
"image": "blahblahblah.azurecr.io/superneatmodule:0.0.2-amd64.debug",
"imageHash": "sha256:ladkjsfaldkjfasdflkjasdfljasfljkasflja4",
"createOptions": "{}",
"env":{}