So according to this issue on GitHub, support for IQueryable
was dropped for v2 Azure Functions. This is also reflected in the official docs. That doc also mentions that CloudTable
could be used to bind to Table storage, however no specific information or examples are provided.
In a minimal working example, how would a Table Storage binding for a v2 Azure Function look like (for, say, reading all rows of a table from table storage)?
Any help is highly appreciated!
Add a comment
|
Should be as simple as
[FunctionName("TestFunction")]
public static async Task Run(
[QueueTrigger("test-queue")] string message,
[Table("testTable")] CloudTable testTable)
{
var querySegment = testTable.ExecuteQuerySegmentedAsync(new TableQuery<ResultEntity>(), null);
foreach (ResultEntity item in querySegment.Result)
{
// Access table storage items here
}
}
A full working example is available here.
-
1Cheers @Mikhail for the quick response. Using
ExecuteQuery
yields to'CloudTable' does not contain a definition for 'ExecuteQuery' and no extension method 'ExecuteQuery' accepting a first argument of type 'CloudTable' could be found (are you missing a using directive or an assembly reference?) [readCtab]
. I includedusing Microsoft.WindowsAzure.Storage.Table;
from PackageWindowsAzure.Storage
. I tried with both Version 8.6.0 and 9.0 with no success. – Mike Floyd Feb 22 '18 at 11:22 -
1@MikeFloyd I copied it from full .NET framework example. I've now updated the sample with
ExecuteQuerySegmentedAsync
which I used on .NET Standard. Could you try this one? – Mikhail Shilkov Feb 22 '18 at 11:36 -
1your example still required some fiddling around, but it definitely pointed me in the right direction. I have a working example now, see my answer below. Full example here. Thanks a lot for your pointers! – Mike Floyd Feb 22 '18 at 14:28
-
1I was missing the Table attribute, having only these Nuget packages in my .NET Standard 2.0 project: Microsoft.NET.Sdk.Functions 1.0.23 and NETStandard.Library 2.0.3. After digging I found out that this attribute is in package Microsoft.Azure.WebJobs.Extensions.Storage 3.0.1, which I had to include. – Artemious Oct 23 '18 at 15:31
-
1Just a note: this is not working with the latest SDKs. You'll end up with an error saying
Can't bind Table to type Microsoft.WindowsAzure.Storage.Table.CloudTable'.
- possible reason: github.com/Azure/azure-functions-host/issues/3784 – Krumelur Jul 15 '19 at 19:39