0
目前,我有一個物聯網設備模擬器,它發送信息給IOT HUB蒙山下面的C#代碼Azure存儲查詢表返回NULL列
for (int i = 0; i < 50; i++)
{
int cnt = new Random().Next(1, 5);
int Id = new Random().Next(1, 10);
var telemetryDataPoint = new
{
Time = DateTime.Now,
DeviceId = "myFirstDevice",
Counter = cnt,
RestId = Id,
};
var messageString = JsonConvert.SerializeObject(telemetryDataPoint);
var message = new Message(Encoding.ASCII.GetBytes(messageString));
await deviceClient.SendEventAsync(message);
Console.WriteLine("{0} > Sending message: {1}", DateTime.Now, messageString);
}
現在我有嘗試讀取數據的另一個C#控制檯應用程序蔚藍的表存儲作爲
public class SimulatorDeviceEntity : TableEntity
{
public SimulatorDeviceEntity(string devId, string time)
{
this.PartitionKey = devId;
this.RowKey = time;
}
public SimulatorDeviceEntity() { }
public string counter { get; set; }
public string restid { get; set; }
public string deviceid { get; set; }
}
static void Main(string[] args)
{
StorageCredentials creds = new StorageCredentials(accountName, accountKey);
CloudStorageAccount account = new CloudStorageAccount(creds, useHttps: true);
CloudTableClient client = account.CreateCloudTableClient();
TableQuery<SimulatorDeviceEntity> query = new TableQuery<SimulatorDeviceEntity>().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "myFirstDevice"));
foreach (SimulatorDeviceEntity entity in table.ExecuteQuery(query))
{
Console.WriteLine("{0}, {1}\t{2}\t{3}", entity.PartitionKey, entity.RowKey,
entity.counter, entity.restid);
}
}
現在的問題,我現在面臨這裏我得到的是我得到的表,但與 1)空條目的所有記錄中的列種臺,restId在PartitionKey2)正確的價值觀和RowKey
如何獲得計數器正確的價值觀和restid
Azure存儲表:SimulatorDevice2這裏是截圖 enter image description here
您還可以分享將消息添加到表存儲的代碼嗎?這將有助於弄清楚發生了什麼事情。 –
模擬器發送消息到IOT HUB,我已經使用Stream Analytics將數據放入Azure表中,查詢如下SELECT DeviceId,RestId,Time,Counter INTO v2deviceOutput from v2deviceInput WHERE DeviceId不爲null注意:v2deviceInput而v2deviceOutput是輸入輸出配置流分析 –
@VaibhavRamteke,任何運氣呢? – Jackie