Azure precompiled feature and CloudTable binding output not working

I am using a precompiled Azure Function that looks like:

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

The printout is as follows:

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

When I remove the schedulerTable parameter from my function, it works. "The message that the host throws in my face:

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

Indeed, when I add a table output binding trying to use different alternatives, nothing works. Alternatives that do not work:

  • The schedulerTable parameter with the type SchedulerRegister. The SchedulerRegister class inherits from TableEntity.
  • The schedulerTable parameter with type ICollector.
  • The schedulerTable parameter with type CloudTable. (higher).

Please ¿How can I fix this? (Use output binding to azure table)

+4
3

, . SDK ? , SDK , , 7.2.1.

, , SDK 7.2.1 .

+8

, , . , .

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; }
}

, , , , , ​​ Azure.

document Azure.

+1

, - ( ) Azure Functions, , , . , , DLL. , .

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

+1
source

Source: https://habr.com/ru/post/1669993/


All Articles