简体   繁体   中英

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.

I have created an event grid subscription on blob storage with a hybrid connection.

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. In other words, there is no listener on this Pub/Sub model.

In your scenario, the event from the event driven blob storage is pushed to the Azure Relay service with a Hybrid Connections. Note, that the Hybrid Connections uses Websockets on port 443 with SSL (https). More details about the Azure Relay Hybrid Connections protocol can be found here .

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.

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.

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:

在此处输入图片说明

Using a SignalRService extension for function is very straightforward, see the following example:

    #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:

    {
        "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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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