public async Task Run([EventGridTrigger] EventGridEvent eventGridEvent, IBinder binder)
        {
            if (eventGridEvent == null || !EventMappings.TryGetValue(eventGridEvent.EventType.ToLowerInvariant(), out var target))
            {
                _log.LogInformation($"Unrecognized event type: {eventGridEvent?.EventType}, skipping");
                return;
            }

            var dtName = eventGridEvent.Topic.Split("/", StringSplitOptions.RemoveEmptyEntries).Last();
            var dtId   = eventGridEvent.Subject;
            var evt    = JsonConvert.DeserializeObject <JObject>(eventGridEvent.Data.ToString());
            var data   = evt["data"];

            _log.LogInformation($"Received event from {dtName} for {dtId} with content {data.ToString()}");

            var messages = binder.Bind <IAsyncCollector <SignalRMessage> >(
                new SignalRAttribute
            {
                HubName = EndpointService.EncodeInstanceNameForSignalR(dtName)
            });

            await messages.AddAsync(new SignalRMessage
            {
                Target    = target,
                Arguments = new[] { new { dtId, data } }
            });
        }
        public async Task <HttpResponseMessage> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "POST", Route = "signalr/negotiate")] HttpRequest req,
            IBinder binder)
        {
            var rpr = _requestProcessor.Process(req);

            if (!rpr.IsSuccess)
            {
                return(HttpUtilities.BadRequest(rpr.Message));
            }

            await SetupEndpointAsync(rpr.Context.InstanceName);
            await SetupRouteAsync(rpr.Context);

            var hubName        = EndpointService.EncodeInstanceNameForSignalR(rpr.Context.InstanceName);
            var connectionInfo = binder.Bind <SignalRConnectionInfo>(
                new SignalRConnectionInfoAttribute
            {
                HubName = hubName,
                UserId  = Guid.NewGuid().ToString()
            });

            _log.LogInformation($"Negotiated connection to {hubName}");
            return(HttpUtilities.Ok(connectionInfo));
        }