Azure / azure-functions-dotnet-worker

Azure Functions out-of-process .NET language worker
MIT License
407 stars 167 forks source link

TableInput for single entity returns array with all entities in that partition #2320

Open jsquire opened 4 months ago

jsquire commented 4 months ago

Issue Transfer

This issue has been transferred from the Azure SDK for .NET repository, #40960. Additional discussion can be found in the comment thread there.

Functions Team: The Azure SDK team is unable to reproduce this issue with the Microsoft.Azure.WebJobs.Extensions.Tables package. This seems as if if may be another instance of the isolated worker parameter bindings initialization bug.
//cc: @fabiocav, @surgupta-msft

Please be aware that @patrick11994 is the author of the original issue and include them for any questions or replies.

Details

I am using the TableInput binding with a partionkey and a rowkey to retrieve a single entity in the table.

[Function("SomeFunction")]
public HttpResponseData Run(
    [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "somefunction/{paramname}")] HttpRequestData req,
    [TableInput("someTable", "somePartition", "{paramname}")] SomeEntity someEntity)
{
    // Removed to keep it on-topic šŸ˜Š
}

This results in the error:

Cannot convert input parameter 'someEntity' to type 'Namespace.For.Entity.SomeEntity' from type 'System.String'

Now using an IEnumerable as input parameter type for the TableInput, like this:

[Function("SomeFunction")]
public HttpResponseData Run(
    [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "somefunction/{paramname}")] HttpRequestData req,
    [TableInput("someTable", "somePartition", "{paramname}")] IEnumerable<SomeEntity> someEntities)
{
    // Removed to keep it on-topic šŸ˜Š
}

Results in no error, and gives me all rows back from somePartition, ignoring the row key

Even when hardcoding a row key inside the TableInput, this is still happening:

[Function("SomeFunction")]
public HttpResponseData Run(
    [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "somefunction")] HttpRequestData req,
    [TableInput("someTable", "somePartition", "someRowKey")] IEnumerable<SomeEntity> someEntities)
{
    // Removed to keep it on-topic šŸ˜Š
}

This returns all rows inside somePartition, ignoring the row key.

Issue Azure/azure-functions-dotnet-worker#1233 is about the same and tells me that this should be resolved, but it is not.

Using NuGet packages:

And Azurite

svrooij commented 3 months ago

I've found a trick, above the TableInput you add

string paramName, with the exact same name in the route and in the RowKey property.

madameczek commented 2 months ago

I've found a trick, above the TableInput you add

string paramName, with the exact same name in the route and in the RowKey property.

Can you clarify, what you mean. pls?