When looking at the signature of the TableClient.QueryAsync method in Azure.Data.Tables SDK, it is not clear how to use it. It returns a AsyncPageable<T>. Fortunately that again implements the IAsyncEnumerable<T>, which means that we can use the Fsharp.Control.TaskSeq library to get the resulting entities.
- Install FSharp.Control.TaskSeq NuGet-package to your project.
open FSharp.Control
- Write your code using the
TaskSeq
module
let getPartitionRows (tableClient: TableClient) (partition: string) =
task {
return!
tableClient.QueryAsync<TableEntity>(filter = $"PartitionKey eq '{partition}'")
|> TaskSeq.map fromEntity
|> TaskSeq.toArrayAsync
}
This is written as a reminder to myself, so that I can easily find it again