0

我正在尝试从我的 Azure 移动服务中的 API 函数发送 serviceBusQueue 消息,即使它成功创建了 queueService 并且队列存在,但我得到了一个令人讨厌的异常。任何线索我如何解决这个问题?

我附上了发送代码和堆栈跟踪。

function sendBusMessage(request, params, message, success)
{
  console.log(params);
  var queueService = azure.createServiceBusService(params.namespace,params.key);
  console.log(queueService);
  if (queueService)
  {
    queueService.sendQueueMessage('worker', message, function (error) 
    {
        if (!error) 
        {
            success();
        }
        else 
        {
            request.respond(statusCodes.INTERNAL_SERVER_ERROR,error);
        }
    });
  }
}

异常堆栈:

发生未处理的异常。TypeError:无法在 ServiceClient._performRequest.self._buildRequestOptions.operation (D:\home\site\wwwroot\node_modules\azure\lib\services\core\serviceclient.js:210:34) 在 ServiceClient 设置属性“body”为 null ._performRequest (D:\home\site\wwwroot\node_modules\azure\lib\services\core\serviceclient.js:264:7) 在 ServiceBusService.ServiceClient._initDefaultFilter.filter (D:\home\site\wwwroot\node_modules\ azure\lib\services\core\serviceclient.js:534:7) 在 ServiceClient._performRequest (D:\home\site\wwwroot\node_modules\azure\lib\services\core\serviceclient.js:261:10) 在 ServiceBusServiceClient ._buildRequestOptions (D:\home\site\wwwroot\node_modules\azure\lib\services\core\servicebusserviceclient.js:107:5) 在 Wrap.signRequest (D:

4

2 回答 2

2

命名空间

namespace用于配置 Node.js 的选项卡在选项卡下可见(Service Bus非常简单)。

访问密钥

不幸的是,它很容易与为特定消息传递功能实例(例如队列)定义的访问键混淆。提供无效的访问密钥可能会导致类似问题的堆栈跟踪。

access key应该用于配置 Node.js 的是可以从窗口Connection Information访问的。要到达那里,您需要导航到Service Bus主选项卡(带有云图标的选项卡),然后单击底部栏中的Connection Information可用按钮。它位于该部分的右下方。Default KeyDEFAULT ISSUER

配置命名空间和访问密钥

两者namespaceaccess key都可以直接传递给azure.createServiceBusService()函数,或者(在配置移动服务时)通过配置部分中的AZURE_SERVICEBUS_NAMESPACEAZURE_SERVICEBUS_ACCESS_KEY键进行设置app settings

于 2014-09-23T21:34:14.177 回答
0

确保您使用的是服务总线->命名空间中的顶级配置,而不是树中更深的任何东西。不正确的访问密钥不会引发有用的异常(例如“无法使用队列密钥访问命名空间”),而是会产生上述问题。

于 2014-08-16T13:02:08.137 回答