2017-10-11 88 views
0

我无法通过ServiceBusQueueTrigger触发Azure函数。Azure函数不触发

这是我有:

Azure的功能:

namespace FunctionApp1 
{ 
    public static class Function1 
    { 
     [FunctionName("Function1")] 
     public static void Run([ServiceBusTrigger("ngctestqueue", AccessRights.Manage, Connection = "AzureWebJobsServiceBus")]string myQueueItem, TraceWriter log) 
     { 
      log.Info($"C# ServiceBus queue trigger function processed message: {myQueueItem}"); 
     } 
    } 
} 

host.json {

}

local.settings.json

{ 
    "IsEncrypted": false, 
    "Values": { 
    "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=ngctest2;AccountKey=STORAGE_ACCOUNT_KEY;EndpointSuffix=core.windows.net", 
    "AzureWebJobsDashboard": "DefaultEndpointsProtocol=https;AccountName=ngctest2;AccountKey=STORAGE_ACCOUNT_KEY;EndpointSuffix=core.windows.net", 
    "AzureWebJobsServiceBus": "Endpoint=sb://ngcservicebus.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=SERVICE_BUS_KEY", 
    "connection": "Endpoint=sb://ngcservicebus.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=SERVICE_BUS_KEY" 
    } 
} 

当我通过F5在本地运行的功能,它不会引发即使有尚未被处理:在队列中的消息

    %%%%%% 
       %%%%%% 
      @ %%%%%% @ 
      @@ %%%%%%  @@ 
     @@@ %%%%%%%%%%% @@@ 
    @@  %%%%%%%%%%  @@ 
     @@   %%%%  @@ 
     @@  %%%  @@ 
      @@ %%  @@ 
       %% 
       % 

[10/11/2017 4:51:13 PM] Host has been specialized 
Listening on http://localhost:7071/ 
Hit CTRL-C to exit... 
[10/11/2017 4:51:13 PM] Reading host configuration file 'C:\Users\User1\source\r 
epos\FunctionApp1\FunctionApp1\bin\Debug\net461\host.json' 
[10/11/2017 4:51:13 PM] Host configuration file read: 
[10/11/2017 4:51:13 PM] { 
[10/11/2017 4:51:13 PM] 
[10/11/2017 4:51:13 PM] } 
[10/11/2017 4:51:14 PM] Loaded custom extension 'BotFrameworkConfiguration' 
[10/11/2017 4:51:14 PM] Loaded custom extension 'SendGridConfiguration' 
[10/11/2017 4:51:14 PM] Loaded custom extension 'EventGridExtensionConfig' 
[10/11/2017 4:51:14 PM] Generating 1 job function(s) 
[10/11/2017 4:51:14 PM] Starting Host (HostId=intelpc-1600078640, Version=1.0.11 
232.0, ProcessId=27016, Debug=False, Attempt=0) 
[10/11/2017 4:51:14 PM] Found the following functions: 
[10/11/2017 4:51:14 PM] FunctionApp1.Function1.Run 
[10/11/2017 4:51:14 PM] 
[10/11/2017 4:51:14 PM] Executing HTTP request: { 
[10/11/2017 4:51:14 PM] "requestId": "755084c1-3501-4e99-8629-8a9a48a60776", 
[10/11/2017 4:51:14 PM] "method": "GET", 
[10/11/2017 4:51:14 PM] "uri": "/" 
[10/11/2017 4:51:14 PM] } 
[10/11/2017 4:51:14 PM] Executed HTTP request: { 
[10/11/2017 4:51:14 PM] "requestId": "755084c1-3501-4e99-8629-8a9a48a60776", 
[10/11/2017 4:51:14 PM] "method": "GET", 
[10/11/2017 4:51:14 PM] "uri": "/", 
[10/11/2017 4:51:14 PM] "authorizationLevel": "Anonymous" 
[10/11/2017 4:51:14 PM] } 
[10/11/2017 4:51:14 PM] Response details: { 
[10/11/2017 4:51:14 PM] "requestId": "755084c1-3501-4e99-8629-8a9a48a60776", 
[10/11/2017 4:51:14 PM] "status": "OK" 
[10/11/2017 4:51:14 PM] } 
[10/11/2017 4:51:14 PM] Host lock lease acquired by instance ID '000000000000000 
00000000017FED4C5'. 
Debugger listening on [::]:5858 
[10/11/2017 4:51:16 PM] Job host started 

问题:我在做什么错了,为什么这不会触发来处理队列中的消息?

我的开发环境如下:

1)的Windows 8.1专业版

2)VS2017社区15.3.5

3)天青功能的CLI 1.0.4

附加信息 在门户网站中显示我的队列没有消息,但在Cloud Explorer中显示它们。这怎么可能?

enter image description here

enter image description here

任何帮助将真正理解。

谢谢。

+0

你能仔细检查您的队列的名称是“ngctestqueue” –

+0

是它!我还添加了图片。 – CloudDev

回答

1

Cloud Explorer显示Azure存储队列,而不是服务总线队列。那些是不同的东西。

看起来你在两个服务中都有同名的队列。请将绑定和你想要的信息对齐。

+0

这是迟缓的..应该有更好的工具! – CloudDev

+0

您可以使用[Service Bus Explorer](https://code.msdn.microsoft.com/windowsapps/Service-Bus-Explorer-f2abca5a)检查SB消息。但我同意,工具可能会更好。 – Mikhail

1

要添加到@ Mikhail的评论中,您的邮件位于Azure存储队列中,但是,您有一个正在查看服务总线队列的Azure功能。

选项:

  1. 改变触发使用存储队列触发,并提供给它的连接。
  2. 写邮件到服务总线队列,而不是存储队列