如何添加 notifcationhubs 库

How do you add notifcationhubs library

如何将 notificationhubs 库包含到 azure 函数中?这是我的尝试,但没有用

using System;
using System.Threading.Tasks;
using System.Collections.Generic;
using Microsoft.Azure.NotificationHubs;

public static void Run(string myQueueItem, TraceWriter log)
{
   log.Info($"C# Queue trigger function processed: {myQueueItem}");
   Notification a;

}

https://github.com/Azure/azure-webjobs-sdk-extensions/blob/75c3f9fb10a44ef80ae9b9a4d655beac4d8fe9f8/src/ExtensionsSample/Samples/NotificationHubSamples.cs 中的示例应该有所帮助。如果您还有其他问题,请告诉我。

我们会将 NotificationHubs 添加到内置程序集列表中,但现在您可以通过为您的 project.json 文件添加对 NoficationHubs 的包引用函数(如文档 here 中所述)。

{
  "frameworks": {
    "net46":{
      "dependencies": {
        "Microsoft.Azure.NotificationHubs": "1.0.5"
      }
    }
   }
}

有了它,您可以为 NotificationHubs 添加一个 using 语句,例如:

using System.Net;
using Microsoft.Azure.NotificationHubs;

public static HttpResponseMessage Run(
    HttpRequestMessage req, 
    TraceWriter log, 
    out Notification notification)
{
    log.Info($"C# HTTP trigger function RequestUri={req.RequestUri}");

    // TODO
    notification = null;

    return req.CreateResponse(HttpStatusCode.OK);
}