Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Storage Explorer Query where by Timestamp

it's my first time working with Azure Storage Explorer and I need to read some logs that is save into Azure Tables. The version of mine is 4

I read this reference http://msdn.microsoft.com/library/azure/ff683669.aspx but there is not explanation to work with the column Timestamp.

Basically, I want to see logs since a specific date.

I tried query like;

Timestamp ge '4/10/2013' Timestamp ge 4/10/2013 Timestamp gt '4/10/2013'
Timestamp gt 4/10/2013

And the result is only a error message.

An error occurred while processing this request.

like image 357
CidaoPapito Avatar asked Apr 23 '14 09:04

CidaoPapito


3 Answers

It looks like you would need to use something like below in order to filter on a Timestamp. Please look at Filtering on DateTime Properties here.

Timestamp ge datetime'2008-07-10T00:00:00Z'

like image 68
Veena Udayabhanu - MSFT Avatar answered Sep 20 '22 11:09

Veena Udayabhanu - MSFT


Use TableQuery.GenerateFilterConditionForDate() methods to set datetime based query parameters against Azure table storage tables:

using Microsoft.WindowsAzure.Storage.Table;

// Input parameters to your method, etc:
DateTimeOffset from;
DateTimeOffset until;

string DateFromFilter = TableQuery.GenerateFilterConditionForDate("Date", QueryComparisons.GreaterThanOrEqual, from);
string DateUntilFilter = TableQuery.GenerateFilterConditionForDate("Date", QueryComparisons.LessThanOrEqual, until);

finalFilter is just a string which you build up using TableQuery methods such as CombineFilters():

finalFilter = TableQuery.CombineFilters(finalFilter, TableOperators.And, DateFromFilter);
finalFilter = TableQuery.CombineFilters(finalFilter, TableOperators.And, DateUntilFilter);

TableQuery<MyAzureObject> query = new TableQuery<MyAzureObject>().Where(finalFilter);
like image 25
Adrian K Avatar answered Sep 17 '22 11:09

Adrian K


This is how you could do it:

var dateFilter = "(PartitionKey ge '0" + StartTime.Ticks + "')" + "and (PartitionKey le '0" + EndTime.Ticks + "')";

StartTime and EndTime will be your date range. Remember that you can only query over PartitionKey because it has index.

like image 45
mrDev Avatar answered Sep 19 '22 11:09

mrDev