简体   繁体   English

天蓝色存储事件可以用于网络农场吗

[英]can azure storage events be used for web farm

I want to know if anyone has used event grid subscription (on blob storage) in a web farm setting.我想知道是否有人在网络场设置中使用过事件网格订阅(在 blob 存储上)。

I have created an event grid subscription on blob storage with a hybrid connection.我使用混合连接在 blob 存储上创建了一个事件网格订阅。

If you have several (listener) applications, can you configure an event grid subscription that can "hit" each application?如果您有多个(侦听器)应用程序,您能否配置一个可以“命中”每个应用程序的事件网格订阅?

The Azure Event Grid is a Pub/Sub model for pushing (distributing) the events to the subscribers based on their subscription such as a logical connectivity metadata. Azure 事件网格是一种发布/订阅模型,用于根据订阅者的订阅(例如逻辑连接元数据)向订阅者推送(分发)事件。 In other words, there is no listener on this Pub/Sub model.换句话说,此 Pub/Sub 模型上没有侦听器。

In your scenario, the event from the event driven blob storage is pushed to the Azure Relay service with a Hybrid Connections.在您的方案中,来自事件驱动的 blob 存储的事件通过混合连接推送到 Azure 中继服务。 Note, that the Hybrid Connections uses Websockets on port 443 with SSL (https).请注意,混合连接在端口 443 上使用带有 SSL (https) 的 Websocket。 More details about the Azure Relay Hybrid Connections protocol can be found here .可以在此处找到有关 Azure 中继混合连接协议的更多详细信息。

Based on this protocol, your receivers on the same Azure Relay Hybrid Connections will balanced , in other words, the Azure Relay Hybrid Connections didn't support the UDP port.基于此协议,同一 Azure 中继混合连接上的接收器将保持平衡,换句话说,Azure 中继混合连接不支持 UDP 端口。

The solution for your scenario (the event message broadcasting) is using an EventGridTrigger function with a SignalR Service output binding as a subscriber for your event driven blob storage.您的方案(事件消息广播)的解决方案是使用EventGridTrigger函数和SignalR 服务输出绑定作为事件驱动的 blob 存储的订阅者。

Update:更新:

The following screen snippet shows broadcasting an event from the blob storage to the web farm servers based on the AEG and SignalR Service integrated with an EventGridTrigger function:以下屏幕片段显示了基于与 EventGridTrigger 功能集成的 AEG 和 SignalR 服务将事件从 blob 存储广播到网络场服务器:

在此处输入图片说明

Using a SignalRService extension for function is very straightforward, see the following example:对函数使用SignalRService扩展非常简单,请参见以下示例:

    #r "Microsoft.Azure.WebJobs.Extensions.SignalRService"

    using Microsoft.Azure.WebJobs.Extensions.SignalRService;

    public static async Task Run(string eventGridEvent, IAsyncCollector<SignalRMessage> signalRMessages, ILogger log)
    {
        log.LogInformation(eventGridEvent);

        await signalRMessages.AddAsync(
            new SignalRMessage
            {
                Target = "Broadcasting",
                Arguments = new[] {eventGridEvent }
            });  
    }

and the function.json:和function.json:

    {
        "bindings": [
         {
          "type": "eventGridTrigger",
          "name": "eventGridEvent",
          "direction": "in"
         },
         {
            "type": "signalR",
            "name": "signalRMessages",
            "hubName": "mySignalRHubName",
            "connectionStringSetting": "AzureSignalRConnectionString",
            "direction": "out"
         }
         ],
        "disabled": false
    }

Another option if you aren't married to using Azure Tables, is using Cosmos DB with Azure Functions and SignalR.如果您不习惯使用 Azure 表,另一种选择是将 Cosmos DB 与 Azure Functions 和 SignalR 结合使用。 I've done something like this for another project, very scalable and near real time.我为另一个项目做过这样的事情,非常可扩展且接近实时。

Broadcast Real-time Updates from Cosmos DB with SignalR Service and Azure Functions 使用 SignalR 服务和 Azure 函数从 Cosmos DB 广播实时更新

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

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