none
Azure Functions integration with Table Storage (out binding) is not working. RRS feed

  • Question

  • Hi!

    I have a simple Azure Function:

    using System;

    public static void Run(TimerInfo myTimer, out CheckResult tableBinding, TraceWriter log)
    {
        log.Info($"Start Test{DateTime.Now}");
        tableBinding = new CheckResult()
                            {
                                PartitionKey = Guid.NewGuid().ToString(),
                                RowKey=string.Empty,
                                Data = Guid.NewGuid().ToString()
                            };

    }

    public class CheckResult
    {
        public string PartitionKey { get; set; }

        public string RowKey { get; set; }

        public string Data { get; set; }
    }

    and config

    {
      "disabled": false,
      "bindings": [
        {
          "name": "myTimer",
          "type": "timerTrigger",
          "direction": "in",
          "schedule": "0 * * * * *"
        },
        {
          "tableName": "testtable",
          "connection": "...",
          "name": "tableBinding",
          "type": "table",
          "direction": "out"
        }
      ]
    }

    The main task of this function is testing the integration with Table Storage. But while running it I get the error:

    Error:

    Function (MyFunctionZ62) Error: Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.MyFunctionZ62'. Microsoft.Azure.WebJobs.Host: Object reference not set to an instance of an object.

    Session Id: 3d17817524b549f1a89e824c32224348

    Timestamp: 2016-08-11T10:52:39.150Z

    Thursday, August 11, 2016 11:05 AM

All replies

  • The underlying issue is that the Table output binding doesn't support binding to a singleton. I'll be investigating why the error message wasn't better in this case, but to unblock yourself, if you change your code to use ICollector (as below) it will work.

    using System;
    using Microsoft.Azure.WebJobs;
    using Microsoft.Azure.WebJobs.Host;
    
    public static void Run(TimerInfo myTimer, ICollector<CheckResult> tableBinding, TraceWriter log)
    {
        log.Info($"Start Test{DateTime.Now}");
        var checkResult = new CheckResult()
        {
            PartitionKey = Guid.NewGuid().ToString(),
            RowKey=string.Empty,
            Data = Guid.NewGuid().ToString()
        };
        tableBinding.Add(checkResult);
    }



    Mathew Charles [MSFT]

    Friday, August 12, 2016 7:05 PM