0
votes

Good Morning I have a question, why I did not use this code in azure function? https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-table#input---c-script-example---one-entity They give me this error:`

Funkce (dbC4/TimerTrigger1) Chyba: Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.TimerTrigger1'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'database' to type Data. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).

` please help me

here is the function.json:

{
  "bindings": [
    {
      "name": "myTimer",
      "type": "timerTrigger",
      "direction": "in",
      "schedule": "0 */5 * * * *"
    },
    {
      "type": "table",
      "name": "databas",
      "tableName": "dbc",
      "partitionKey": "Test",
      "rowKey": "test3",
      "take": "50",
      "connection": "AzureWebJobsStorage",
      "direction": "in"
    }
  ],
  "disabled": false
}

here is run.cvsx:

using System;

public static void Run(TimerInfo myTimer, Data database, ILogger log)

{
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");

log.LogInformation($"Name in Database entity: {database.Name}");

}

public class Data
{
    public string PartitionKey { get; set; }
    public string RowKey { get; set; }
    public string Name { get; set; }
}
1

1 Answers

0
votes

I test the table binding and it won't hit this error. So I check your code And I find a difference, it's your table binding name doesn't match the run.csx parameter name, one is databas and one is database. Then I change my binding name, then I reproduce your exception.

So the solution is just change them to the same name.

function.json

 {
      "bindings": [
        {
          "name": "myTimer",
          "type": "timerTrigger",
          "direction": "in",
          "schedule": "0 */1 * * * *"
        },

        {
          "name": "databas",
          "type": "table",
          "tableName": "Person",
          "partitionKey": "george",
          "rowKey": "chen",
          "take": "50",
          "connection": "AzureWebJobsStorage",
          "direction": "in"
        }
      ]
    }

run.csx

using System;

public static void Run(TimerInfo myTimer, ILogger log,Data database)
{
    log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
    log.LogInformation($"Name in Person entity: {database.Name}");
}
public class Data
{
    public string PartitionKey { get; set; }
    public string RowKey { get; set; }
    public string Name { get; set; }
    public string ID {get;set;}
}

enter image description here