I am creating a new azure function using HttpTrigger. I want to implement an azure table storage table as input binding. Following a source code example in msdn, I am not able to figure out in which NuGet package the "Table" attribute can be found.
Compile issue:
The type or namespace 'TableAttribute' could not be found (are you missing a using directive or an assembly reference?)
Line of code, causing the issue:
public static async Task<IActionResult>
Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
[Table("AzureWebJobsHostLogscommon")] CloudTable cloudTable,
ILogger log)
The source code examples in MSDN I am refering to can be found here:
https://github.com/MicrosoftDocs/azure-docs/blob/master/articles/azure-functions/functions-bindings-storage-table.md#input---c-example---one-
and here:
https://learn.microsoft.com/de-de/azure/azure-functions/functions-bindings-storage-table#input---c-example---cloudtable
The second example also shows the using directives. But even when copying the example the table-attribute cannot be resolved properly.
I have also seen this stackoverflow thread:
input-binding to table storage with an http-triggered function
but the first solution is only a workaround for me, as the table-storage connection is done during execution of the function and not as input binding. If you see the second proposed solution, it shows same code as in MSDN.
Here is my code:
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Extensions.Logging;
using Microsoft.WindowsAzure.Storage.Table;
using System;
using System.Net;
using System.Threading.Tasks;
namespace TableStorageIntegration.HTTPTrigger
{
public static class Function1
{
[FunctionName("DoSomething")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
[Table("AzureWebJobsHostLogscommon")] CloudTable cloudTable,
ILogger log)
{
string someHttpGetParameter = req.Query["someParameter"];
// ....
// Some addition code to be executed here but not relevant for the issue
// .....
return new OkObjectResult($"Data provided");
}
}
}
Is the proposed implementation still valid? And if yes, which NuGet package do I have to install to resolve the table attribute?
You need to add this NuGet Package: https://nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.Storage
So seems like they have removed TableAttribute
for some reason.
However they are working on bringing it back early 2022.
In the meantime, there are a couple of workarounds if you are using Azure Tables:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With