如何在 Visual Studio 中将 NotificationHub 指定为 Azure Functions 的输出触发器

How can I specify NotificationHub as output Trigger for Azure Functions in Visual Studio

如何在 Visual studio 中为 NotificationHub 指定 azure 函数开发的输出参数: 我的函数如下所示:

        [FunctionName("DoSomething")]
        public static void Run(
            [ServiceBusTrigger("myqueue", AccessRights.Manage, Connection = _Connection)]string queueItem, 
            TraceWriter log,
            [????] IAsyncCollector<Notification> notification)
        {
         //.....   
        }

azure.portal 中的 Azure 函数具有 json 输出配置,但在 visual studio 中的代码中它没有类似 NotificationHub 的装饰器,类似于指定队列输出:[Queue("myQueueName", Connection = "myconnection")] IAsyncCollector<Notification> notification.如何定义具有门户中显示的信息的输出参数?

   {
      "type": "notificationHub",
      "name": "notification",
      "hubName": "mynotification-hub",
      "connection": "CONNECTION",
      "direction": "out",
      "tagExpression": "{Tag}"
    } 

您需要安装 Microsoft.Azure.WebJobs.Extensions.NotificationHubs NuGet 包。

然后像

一样使用触发器
[NotificationHub] out Notification notification

[NotificationHub(HubName = "mynotification-hub", ConnectionStringSetting = "CONNECTION", 
                 TagExpression = "{Tag}")] IAsyncCollector<Notification> notification

更多内容见docs