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> |
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
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 toTableStorage
in Azure v2 functions.