繁体   English   中英

Azure与服务总线一起使用,因为输出绑定不起作用

[英]Azure functions with service bus as output binding not working

我正在尝试通过Java的Azure函数中的输出绑定将消息发送到服务总线。

我正在使用azure函数cli在本地进行测试,并像往常一样将主机作为func host start

我的设置是这样的:

function.json

{
  "disabled": false,

  "bindings": [
    {
      "authLevel": "function",
      "type": "httpTrigger",
      "direction": "in",
      "name": "req",
      "methods": [
        "put"
      ]
    },
    {
      "type": "serviceBus",
      "name" : "locationQueue",
      "queueName": "location_queue",
      "direction": "out",
      "accessRights": "Manage",
      "connection": "service-bus_CONNECTION"
    },
    {
      "type": "http",
      "direction": "out",
      "name": "res"
    }
  ]
}

一些诺言之后的功能是这样结束的:

.then( () => {
        var message = {
            userID : userID,
            lat: userCurrentLocation.lat,
            long: userCurrentLocation.long,
            time: new Date()
        };
        context.bindings.locationQueue = [JSON.stringify(message)];
        context.res = {
            status: 200,
            body: ''
        }
        context.done();
    })
    .catch( (err) => {
        console.error("Error while trying to update userID %s location.", userID, err)
        context.res = {
            status: 500,
            body: ''
        }
        context.done();
    })

该请求成功以200状态代码结束。

连接字符串是由azure门户生成的,似乎正在连接,因为我测试时仪表板会显示新连接。 我什至尝试输入错误的连接字符串,但函数主机根本没有抱怨!

但是没有创建队列,也没有消息发送。 我尝试自己创建队列,但消息也未发送。

怎么了? 我做错了什么? 而且,如果我做错了什么,即使在日志中也不会收到错误消息? 我的意思是,如果没有发送消息并且没有记录任何错误,我怎么能相信一切正确?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM