Reputation: 2022
I am trying to create an Azure Function with a ServiceBus Queue trigger and an additional input data. That is the function should trigger on blob update giving the blob name as input. I want to have a Blob data as an additional input.
The function.json created is as below.
{
"bindings": [
{
"name": "myQueueItem",
"type": "serviceBusTrigger",
"direction": "in",
"queueName": "afqueue",
"connection": "CONNECTIONSTRING",
"accessRights": "Listen"
},
{
"type": "blob",
"name": "inputBlob",
"path": "samplecontainer/{name}",
"connection": "AzureWebJobsDashboard",
"direction": "in"
}
],
"disabled": false
}
The function signature defined is as follows.
public static void Run(string myQueueItem, Stream inputBlob, TraceWriter log){}
This gives an error as below
Function ($ServiceBusQueueTriggerCSharp1) Error: Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.ServiceBusQueueTriggerCSharp1'. Microsoft.Azure.WebJobs.Host: No binding parameter exists for 'name'.
Instead of paramter {name}, if a hardcoded value is given the function is working properly. How to do the binding to input data variable.
Upvotes: 0
Views: 1863
Reputation: 35144
Input binding can be templated from trigger parameters. So, name
should be part of your service bus message payload. You could implement the function like this:
public class MyQueueItem
{
public string name { get; set; }
}
public static void Run(MyQueueItem myQueueItem, Stream inputBlob, TraceWriter log)
{}
Note that the only trigger for this function are Service Bus messages. The function will NOT be triggered by blob updates, unless some other code of yours sends a Service Bus message with blob name for each update in the system.
Upvotes: 1