3
votes

I have a python function with a servicebus trigger and a blob input binding. The name of the blob match the content of the queue message. My function.json file looks like that:

{
"bindings": [
    {
    "type": "serviceBusTrigger",
    "name": "inputMessage",
    "connection": "Omnibus_Validation_Listen_Servicebus",
    "queueName": "validation-input-queue",
    "accessRights": "listen",
    "direction": "in"
    },
    {
    "type": "blob",
    "name": "inputBlob",
    "path": "baselines/{inputMessage}",
    "connection": "Omnibus_Blob_Storage",
    "direction": "in"
    }
],
"disabled": false
}

And it is working like a charm.

I'd to create a C# function with the same bindings but it does not seem to work. I've used the same function.json file.

I have a project.json file:

{
    "frameworks": {
        "net46": {
            "dependencies": {
                "WindowsAzure.Storage": "8.5.0"
            }
        }
    }
}

and my run.csx file looks like that:

public static void Run(string inputMessage, Stream inputBlob, TraceWriter log)
{
    log.Info($"C# ServiceBus queue trigger function processed message: {inputMessage}");
}

When I save/run the function, I received this error:

Function ($import-baseline) Error: Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.import-baseline'. Microsoft.Azure.WebJobs.Host: No binding parameter exists for 'inputMessage'.

Is there any difference between the python and c# sdk for this kind of binding ?

1
Looks ok. Try removing project.json, it's not needed in this case.Mikhail Shilkov
@Mikhail, Not working :-(Thomas
Yes... the problem is with baselines/{inputMessage} syntax. But funny that it works in python...Mikhail Shilkov
Yeah I know for queueTrigger the syntax is different, I tried baselines/{inputMessage} and it was working. I also tried baselines/{serviceBusTrigger} but no luckThomas
@Thomas I have a question but different from what you asked. I just wanted to know how do you pass {inputMessage} named parameter when you send messages to queue. Do you have Python Example for this some where? I understood that this {inputMessage} should be a named parameter in the queue message. I insert the message using Python SDK and couldn't find any way to pass the named parameter.Rajat Arora

1 Answers

0
votes

I also can reproduce it on my side if I bind input blob path with baselines\{serviceBusTrigger} or baselines\{inputMessage} in the function.json file.

I am not sure whether it is supported to integrated input servicebus queue and input blob currently. We could give our feedback to Azure function team.

If Azure storage queue is acceptable we could use Azure storage queue trigger to do that. I test it on my side, it works correctly.

enter image description here

run.csx file

using System;
using System.Threading.Tasks;

public static void Run(string myQueueItem, Stream inputBlob, TraceWriter log)
{
    log.Info($"C# storage queue trigger function processed message: {myQueueItem}");
    StreamReader reader = new StreamReader(inputBlob);
    string text = reader.ReadToEnd();
    log.Info(text);
}

function.json

{
  "bindings": [
    {
      "type": "blob",
      "name": "inputBlob",
      "path": "incontainer/{queueTrigger}",
      "connection": "testweblog_STORAGE",
      "direction": "in"
    },
    {
      "type": "queueTrigger",
      "name": "myQueueItem",
      "queueName": "myqueue",
      "connection": "testweblog_STORAGE",
      "direction": "in"
    }
  ],
  "disabled": false
}