如何将输出绑定到服务总线?
我在azure函数中设置了out绑定:

{
  "queueName": "testqueue",
  "connection": "MyServiceBusConnection",
  "name": "myQueueItem",
  "type": "serviceBus",
  "direction": "out"
}

我已经开始使用标准的JavaScript/Type脚本模板来实现这个功能:
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; //should 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();
};

我得到了函数的响应,但是没有东西进入服务总线。
我已经为“cc>”设置了我的应用程序设置,因为门户显示:
javascript - 如何从http触发功能输出到服务总线-LMLPHP
我做错什么了?如何将输出绑定到服务总线?
这是完整的MyServiceBusConnection文件:
{
  "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"
}

最佳答案

为什么绑定(myqueueitem)的名称与在代码(context.bindings.outputsbqueue)中调用它的方式不同?

关于javascript - 如何从http触发功能输出到服务总线,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/56212389/

10-12 22:47