1
votes

I'm attempting to use an output table binding with an Azure Function V2 (node).

I have added the table binding to function.json, as described in the documentation.

{
    "tableName": "Person",
    "connection": "MyStorageConnectionAppSetting",
    "name": "tableBinding",
    "type": "table",
    "direction": "out"
}

And then I am attempting to insert some content in to that table, again using the example as described in the documentation.

for (var i = 1; i < 10; i++) {
    context.bindings.tableBinding.push({
        PartitionKey: "Test",
        RowKey: i.toString(),
        Name: "Name " + i
    });
}

To confirm - I have also added a setting called MyStorageConnectionAppSetting in to local.settings.json, with a valid Storage Account connection string as it's value.

Sadly though, this is failing and I'm seeing the following error -

System.Private.CoreLib: Exception while executing function: Functions.config. System.Private.CoreLib: Result: Failure
Exception: TypeError: Cannot read property 'push' of undefined

It seems that the binding object has not be created as expected, but I have no idea why.

The package Microsoft.Azure.WebJobs.Extensions.Storage is included in extensions.csproj, and the Function App starts just fine when I call func start.

Although I believe that no connection to the Storage Account is taking place, I did try to run my function both when the Table existed, and when it didn't.

1

1 Answers

2
votes

Make sure the parameter has been initialized before usage. The output binding is undefined unless it's initialized or assigned value.

context.bindings.tableBinding = [];