简体   繁体   English

如何将 Azure 通知中心与 Azure Functions v2 结合使用

[英]How to use Azure Notification Hubs with Azure Functions v2

I have to register bindings in Functions v2 to use them.我必须在 Functions v2 中注册绑定才能使用它们。 This can be done, for example, as adding corresponding NuGet package.例如,这可以通过添加相应的 NuGet 包来完成。 Azure's docs says that Notification Hubs bindings are not available for Functions v2. Azure 的文档说,通知中心绑定不适用于 Functions v2。 However, I still can add that Nuget package (Microsoft.Azure.WebJobs.Extensions.NotificationHubs) in Visual Studio.但是,我仍然可以在 Visual Studio 中添加 Nuget 包 (Microsoft.Azure.WebJobs.Extensions.NotificationHubs)。 Will it just not work?它不会工作吗? Should I stick to Functions v1 to be able to send notifications?我应该坚持使用 Functions v1 才能发送通知吗? Or is there any new way to send them with Functions v2?或者是否有任何新方法可以使用 Functions v2 发送它们?

It's not a high priority work item for us at the moment, but we have some base work done on migrating the Notification Hubs binding to the Functions v2 runtime.目前,这对我们来说不是一个高优先级的工作项目,但我们已经完成了一些将通知中心绑定迁移到 Functions v2 运行时的基础工作 A developer who wants to use Notification Hubs in Functions v2 today has two options:现在想要在 Functions v2 中使用通知中心的开发人员有两个选择:

  1. Go bindingless and integrate with Notification Hubs via their SDK.去绑定并通过他们的 SDK 与通知中心集成。
  2. Clone the aforementioned branch of the extensions repo.克隆扩展库的上述分支 Building it will give you a NuGet package that can be referenced like any other extension from your project.构建它会给你一个 NuGet 包,它可以像你的项目中的任何其他扩展一样被引用。 Note: You will have to deploy the build artifacts for the NuGet reference to work properly.注意:您必须为 NuGet 引用部署构建工件才能正常工作。

(We're also open source and welcome community contributions!) (我们也是开源的,欢迎社区贡献!)

As Version 1.x is in maintenance mode and Notification Hubs binding continues to be Version 1.x only, I think the best way forward is to use Azure Functions Version 2.x (or 3.x) and access the Notification Hubs via their SDK, as Katy mentioned above .由于版本 1.x 处于维护模式并且通知中心绑定仍然仅限版本 1.x,我认为最好的方法是使用 Azure Functions 版本 2.x(或 3.x)并通过它们访问通知中心SDK,正如 Katy 上面提到的

I've found this sample official Azure project helpful to get you started (the configuration is very minimal): https://github.com/Azure/azure-notificationhubs-dotnet/tree/master/Samples/AzFunctions我发现这个示例官方 Azure 项目有助于您入门(配置非常少): https : //github.com/Azure/azure-notificationhubs-dotnet/tree/master/Samples/AzFunctions

See the SendPushSample and other samples in parent folders for specific use cases.有关特定用例,请参阅父文件夹中的SendPushSample和其他示例。

You lose the clear indication what is an output of an Azure Function, but only for notifications.您无法明确指示 Azure 函数的输出是什么,但仅限于通知。 And given all the improvements in Version 2.x and up (and the fact that it's actively maintained), it seems like a worthy trade-off.考虑到 2.x 版及更高版本的所有改进(以及它得到积极维护的事实),这似乎是一个值得的权衡。

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

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