Reputation: 12007
I have seen that Azure Table Storage supports querying records by a partial RowKey
(in addition to the PartitionKey
) (C# example here).
However, I can't find anything related to this in the actual docs on filtering query results (here).
I am trying to using the Python Azure-Storage SDK to query a subset of PartitionKey
and RowKey
combinations where the RowKey
starts with a certain string. I have the code (which works, but does not do correct filtering any row keys):
from azure.storage.table import TableService
table_service = TableService(account_name=ACCOUNT_NAME, account_key=ACCOUNT_KEY)
entities = table_service.query_entities('mystoragetable', filter='PartitionKey eq mypartitionkey"', num_results=10)
However, I can't figure out the syntax for also adding a partial (startswith
) constraint to the filter.
Has anyone had any experience with filtering Azure Table Storage queries by partial RowKey
strings? I am at a loss here; however, it seems to be possible via the C#
code in the example above.
If there are any extra docs about how to do this via a REST call, I can probably translate that into the Python usage.
Upvotes: 2
Views: 3493
Reputation: 136276
Assuming your RowKey values contains words and you only want to filter the words starting with a
and b
, this is what you would add to your query:
(RowKey ge 'a' and RowKey lt 'c') ==> (RowKey >= 'a' && RowKey < 'c')
So your code would be something like:
entities = table_service.query_entities('mystoragetable', filter="PartitionKey eq 'mypartitionkey' and RowKey ge '<starts with substring>'", num_results=10)
Upvotes: 3