5

I'm using a precompiled Azure Function that looks:

public static async Task Run(Stream inputBlob, Stream outputJson, Stream outputXml, CloudTable schedulerTable)

The output binding looks:

{
  "name": "schedulerTable",
  "type": "table",
  "direction": "out",
  "tableName": "SchedulerTable",
  "connection": "SchedulerTable"
}

When i remove the parameter schedulerTable from my function, it's works. ´The message that the host throws in my face is:

Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.InputFileAdaptorAF'. Microsoft.Azure.WebJobs.Host: Can't bind Table to type 'Microsoft.WindowsAzure.Storage.Table.CloudTable'.

Really, when i add a table output binding trying with diferent alternatives, nothing works. Alternatives that doesn't work are:

  • Parameter schedulerTable with type SchedulerRegister. The class SchedulerRegister inherits from TableEntity.
  • Parameter schedulerTable with type ICollector.
  • Parameter schedulerTable with type CloudTable. (the case above).

Please, ¿How I can fix it? (Use an output binding to azure table)

3 Answers 3

11

You're likely running into type mismatch issues. What version of the storage SDK are you using? You need to make sure storage SDK references match what the runtime expects, which currently is 7.2.1.

Please make sure that you're referencing the storage SDK version 7.2.1.

Sign up to request clarification or add additional context in comments.

2 Comments

I didn't work for me . I changed project storage SDK to version 7.2.1 and verified the AppData\Local\Azure.Functions.Cli\1.0.7 had the same version (7.2.1) of Microsoft.WindowsAzure.Storage.dll.
fyi nearly a year later it's still version 7.2.1 of WindowsAzure.Storage that you should use.
1

According to your description, I have tested this issue about binding to the table output, I could make it work as expected. Here is my code snippet, you could refer to it.

function.json

{
  "bindings": [
    {
      "name": "inputBlob",
      "type": "blobTrigger",
      "direction": "in",
      "path": "input/{name}",
      "connection": "AzureStorageConnectionString"
    },
    {
      "type": "table",
      "name": "outTable",
      "tableName": "UploadFile",
      "connection": "AzureStorageConnectionString",
      "direction": "out"
    }
  ],
  "disabled": false
}
  • ICollector<T>
#r "Microsoft.WindowsAzure.Storage"

using Microsoft.WindowsAzure.Storage.Table;
using Microsoft.WindowsAzure.Storage.Blob;

public static void Run(CloudBlockBlob inputBlob, ICollector<UploadFile> outTable, TraceWriter log)
{   
    string blobUri=inputBlob.StorageUri.PrimaryUri.ToString();
    log.Info($"C# Blob  trigger function triggered, blob path: {blobUri}");

    outTable.Add(new UploadFile()
    {
        PartitionKey = "Functions",
        RowKey = Guid.NewGuid().ToString(),
        Name = blobUri
    });
}

public class UploadFile : TableEntity
{
    public string Name { get; set; }
}
  • CloudTable
#r "Microsoft.WindowsAzure.Storage"

using Microsoft.WindowsAzure.Storage.Table;
using Microsoft.WindowsAzure.Storage.Blob;

public static void Run(CloudBlockBlob inputBlob,CloudTable outTable, TraceWriter log)
{   
    string blobUri=inputBlob.StorageUri.PrimaryUri.ToString();
    log.Info($"C# Blob  trigger function triggered, blob path: {blobUri}");

    outTable.Execute(TableOperation.Insert(new UploadFile()
    {
        PartitionKey = "Functions",
        RowKey = Guid.NewGuid().ToString(),
        Name = blobUri
    }));
}

public class UploadFile : TableEntity
{
    public string Name { get; set; }
}

Modify your code and click Save, if the compilation executes successfully, then when the function is triggered, you could see the following log and the record is added to Azure Table Storage.

For more details, you could refer to this official document about storage table binding for Azure function.

1 Comment

Thank you for the complete answer. But, in mi case, i'm using a compiled azure function, not csx in the azure portal. In the portal, it's works ok. In my precompiled function, It doesn't work.
1

Really, this answer is from someone (i don't remember de name) in the team of Azure Functions, here in this question, but he delete her response. He says that surely the problem is from having diferent version of the dll that expected. I can confirm that these was the problem.

The solution is to check the version of dlls used in AppData\Local\Azure.Functions.Cli\1.0.0-beta.91 and use the same in the solution.

1 Comment

The answer had been deleted in review, so I just updated and "undeleted"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.