Search code examples
azureodataazure-storage

OData query for all rows from the last 10 minutes


I need to filter rows from an Azure Table Store that are less than 10 minutes old. I'm using a Azure Function App integration to query the table, so a coded solution is not viable in this case.

I'm aware of the datetime type, but for this I have to specify an explicit datetime, for example -

Timestamp gt datetime'2018-07-10T12:00:00.1234567Z'

However, this is insufficient as I need the query to run on a timer every 10 minutes.

According to the OData docs, there are built in functions such as totaloffsetminutes() and now(), but using these causes the function to fail.

[Error] Exception while executing function: Functions.FailedEventsCount. Microsoft.WindowsAzure.Storage: The remote server returned an error: (400) Bad Request.

Is there a way to query a Table Store dynamically in this way?


Solution

  • Turns out that this was easier than expected.

    I added the following query filter to the Azure Table Store input integration -

    Timestamp gt datetime'{afterDateTime}'
    

    In conjunction with a parameter in the Function trigger route, and Bob's your uncle -

    FailedEventsCount/after/{afterDateTime}
    

    Appreciate for other use cases it may not be viable to pass in the datatime, but for me that is perfectly acceptable.