azure-webjobs-sdk icon indicating copy to clipboard operation
azure-webjobs-sdk copied to clipboard

Calling IBinder.BindAsync with a TableEntity / TableAttribute leads to NullReferenceException

Open DuncWatts opened this issue 2 years ago • 0 comments

I'm trying to call the following to get an entity. This fetches the table entity correctly as required however after completing the function call I get a NullReferenceException. This is the same regardless of using TableEntity or a class inheriting from ITableEntity.

TableEntity tableEntity = await binder.BindAsync<TableEntity>(new TableAttribute("TableName", partitionKey, rowKey));

Stack trace:

  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=Microsoft.Azure.WebJobs.Extensions.Tables
  StackTrace:
   at Microsoft.Azure.WebJobs.Extensions.Tables.PocoEntityValueBinder`1.<SetValueAsync>d__9.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at Microsoft.Azure.WebJobs.Binder.<Complete>d__14.MoveNext() in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Bindings\Runtime\Binder.cs:line 159

Repro steps

Provide the steps required to reproduce the problem

  1. Created a fresh Azure Function project targetting .net 6
  2. Added Microsoft.Azure.WebJobs.Extensions.Tables 1.0.0
  3. Added IBinder to the function signature along with the line above

Known workarounds

Calling BindAsync<TableClient> then performing a query manually allows me to fetch the entity without an exception.

DuncWatts avatar May 30 '22 12:05 DuncWatts