How can I link the output to service bus?
I've configured an out
binding in my Azure function:
{
"queueName": "testqueue",
"connection": "MyServiceBusConnection",
"name": "myQueueItem",
"type": "serviceBus",
"direction": "out"
}
I started with the standard JavaScript/TypeScript template for the function:
export function run(context: any, req: any): void {
context.log("TypeScript HTTP trigger function processed a request.");
context.log(req.query);
context.bindings.outputSbQueue = req.query; //need to bind here
if (req.query.name || (req.body && req.body.name)) {
context.res = {
// status: 200, /* Defaults to 200 */
body: {
message: `Hello ${(req.query.name || req.body.name)}`
}
};
} else {
context.res = {
status: 400,
body: "Please pass a name on the query string or in the request body"
};
}
context.done();
};
The function is responding, but the data isn't being sent to the service bus.
I've configured the app settings for MyServiceBusConnection
as shown in the portal:
https://i.sstatic.net/Ok7Wr.png
What could be the issue? How can we bind the output to the service bus?
Here's the complete function.json
file:
{
"disabled": false,
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req"
},
{
"type": "http",
"direction": "out",
"name": "res"
},
{
"queueName": "testqueue",
"connection": "MyServiceBusConnection",
"name": "myQueueItem",
"type": "serviceBus",
"direction": "out"
}
],
"scriptFile": "../dist/HttpTriggerTS/index.js"
}