How to retrieve latest record using RowKey in Azure Table storage RRS feed

  • Question

  • Tricky part is RowKey is string which is having value like Mon Nov 14 12:26:42 2016

    I tried query to compare the latest RowKey

      public class MyEntity : TableEntity
            public MyEntity(string partitionKey, string rowKey)
                this.PartitionKey = partitionKey;
                this.RowKey = rowKey;
            public MyEntity() { }
            public Int64 DevideId { get; set; }
            public string RowKey { get; set; }

    //below query gives full data

    // Retrieve the storage account from the connection string.
                CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
                // Create the table client.
                CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
                // Create the CloudTable object that represents the "TemperatureData" table.
                CloudTable table = tableClient.GetTableReference("TemperatureData");
                // retrive data
                TableQuery<TemperatureEntity> query = new TableQuery<TemperatureEntity>();
                var data = table.ExecuteQuery(query);[![enter image description here][1]][1]


    Monday, November 14, 2016 4:58 PM

All replies

  • Hi,

    Thanks for posting here!

    As of now there is no direct way of fetching the latest record using the RowKey property. You may, however, flip the RowKey and list it in reverse chronological order and then fetch the top most entry which would be the latest. Click here to view a blog post that describes this in more detail.



    Md. Shihab

    Disclaimer: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.



    Please remember to click "Mark as Answer" on the post that helps you as this can be beneficial to other community members reading the thread. And vote as helpful.

    • Proposed as answer by Md Shihab Monday, November 28, 2016 9:17 AM
    Tuesday, November 15, 2016 5:58 AM