Currently I have an IOT Device Simulator Which Sends Message to IOT HUB whith following C# code
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);
}
Now I have an another C# console application which tries to read data from the azure table storage as
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);
}
}
Now Issue I am facing here is I get is I am getting all the records from table but with 1 ) null entries in the columns couter,restId 2) correct values in PartitionKey and RowKey
How to get the correct values for counter and restid
Azure Storage Table : SimulatorDevice2 here is the screenshot enter image description here