0

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.

1 Answer 1

1

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.

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

3 Comments

Cheers! This worked. I could not find enough documentation on this.
unless some other code of yours sends a Service Bus message with blob name for each update in the system - when it comes to storage queues, my experience has been that regardless of the type of the message received - even when specifying a strongly-typed object, such as you do with MyQueueItem - the trigger still fires! do you disagree?
Not sure how your question about storage queue is related to my answer

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.