Last active
February 22, 2018 14:35
-
-
Save MrMikeFloyd/16d93f0bace0bd1229f6b7767c96569c to your computer and use it in GitHub Desktop.
Minimal C# Azure Function with an inbound table storage binding, resulting in "Microsoft.Azure.WebJobs.Host: Can't bind Table to type 'System.Linq.IQueryable`1[test.TableRow]'". Created on macOS High Sierra with Visual Studio Code 1.19.3 and .NET Core 2.0.5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"IsEncrypted": false, | |
"Values": { | |
"AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=xxxxxxx;AccountKey=xxxxxxxxxxxxxx", | |
"AzureWebJobsDashboard": "" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.IO; | |
using Microsoft.AspNetCore.Mvc; | |
using Microsoft.Azure.WebJobs; | |
using Microsoft.Azure.WebJobs.Extensions.Http; | |
using Microsoft.AspNetCore.Http; | |
using Microsoft.Azure.WebJobs.Host; | |
using Newtonsoft.Json; | |
using System.Linq; | |
using Microsoft.WindowsAzure.Storage.Table; | |
using System; | |
using System.Net.Http; | |
using System.Net; | |
namespace test | |
{ | |
public class TableRow : TableEntity | |
{ | |
public Int32 valueX { get; set; } | |
public Int32 valueY { get; set; } | |
public Int32 valueZ { get; set; } | |
} | |
public static class read_from_tabstorage | |
{ | |
[FunctionName("read_from_tabstorage")] | |
public static HttpResponseMessage Run( | |
[HttpTrigger(AuthorizationLevel.Function, "get", Route = null)]HttpRequest req, | |
[Table("tabstoragetbl1", "")] IQueryable<TableRow> tRows, | |
TraceWriter log) | |
{ | |
log.Info("C# HTTP trigger function processed a request."); | |
var row = tRows.FirstOrDefault(); | |
if(row != null) | |
{ | |
log.Info($"Data received: {row.valueX}"); | |
} | |
return new HttpResponseMessage(HttpStatusCode.OK); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<TargetFramework>netstandard2.0</TargetFramework> | |
<AzureFunctionsVersion>v2</AzureFunctionsVersion> | |
</PropertyGroup> | |
<ItemGroup> | |
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.6" /> | |
</ItemGroup> | |
<ItemGroup> | |
<None Update="host.json"> | |
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | |
</None> | |
<None Update="local.settings.json"> | |
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | |
<CopyToPublishDirectory>Never</CopyToPublishDirectory> | |
</None> | |
</ItemGroup> | |
</Project> |
Runtime output
Executing with func host start
from the target directory.
[02/10/2018 09:15:50] Reading host configuration file '/Users/xxx/dev/xxx/test-fkt/bin/Debug/netstandard2.0/host.json'
[02/10/2018 09:15:50] Host configuration file read:
[02/10/2018 09:15:50] {}
[02/10/2018 09:15:50] Generating 1 job function(s)
[02/10/2018 09:15:50] Starting Host (HostId=xxx-1595519538, Version=2.0.11415.0, ProcessId=1273, Debug=False, ConsecutiveErrors=0, StartupCount=1, FunctionsExtensionVersion=)
[02/10/2018 09:15:52] A ScriptHost error has occurred
[02/10/2018 09:15:52] Microsoft.Azure.WebJobs.Host: Error indexing method 'read_from_tabstorage.Run'. Microsoft.Azure.WebJobs.Host: Can't bind Table to type 'System.Linq.IQueryable`1[test.TableRow]'.
[02/10/2018 09:15:52] Error indexing method 'read_from_tabstorage.Run'
[02/10/2018 09:15:52] Microsoft.Azure.WebJobs.Host: Error indexing method 'read_from_tabstorage.Run'. Microsoft.Azure.WebJobs.Host: Can't bind Table to type 'System.Linq.IQueryable`1[test.TableRow]'.
[02/10/2018 09:15:52] No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. config.UseServiceBus(), config.UseTimers(), etc.).
[02/10/2018 09:15:52] Job host started
[02/10/2018 09:15:52] The following 1 functions are in error:
[02/10/2018 09:15:52] Run: Microsoft.Azure.WebJobs.Host: Error indexing method 'read_from_tabstorage.Run'. Microsoft.Azure.WebJobs.Host: Can't bind Table to type 'System.Linq.IQueryable`1[test.TableRow]'.
[02/10/2018 09:15:52]
[02/10/2018 09:15:52]
Listening on http://localhost:7071/
Hit CTRL-C to exit...
According to this issue, this is behaviour by design as support for IQueryable
was dropped for v2 functions (reference). Therefore, CloudTable
remains an option when binding to TableStorage
in Azure v2 functions.
Minimal working example for CloudTables
posted here. This seems to be the way to go for v2 functions.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Build output