Example #1
0
        public static HttpResponseMessage Run([HttpTrigger(AuthorizationLevel.Anonymous, "post",
                                                           Route = nameof(PostMessageToQueue))]
                                              HttpRequestMessage req, TraceWriter log)
        {
            using (var analytic = new AnalyticService(new RequestTelemetry
            {
                Name = nameof(PostMessageToQueue)
            }))
            {
                var image = req.GetObject <byte[]>();

                try
                {
                    using (var client = new QueueService("imageprocess"))
                    {
                        client.SendBrokeredMessageAsync(image).Wait();

                        return(req.CreateResponse(HttpStatusCode.OK));
                    }
                }
                catch (Exception e)
                {
                    // track exceptions that occur
                    analytic.TrackException(e);

                    return(req.CreateErrorResponse(HttpStatusCode.BadRequest, e));
                }
            }
        }
Example #2
0
 static void SetEndGameTimer(Game game, AnalyticService analytic)
 {
     try
     {
         var client = new QueueService(Keys.ServiceBus.EndGameBusName);
         client.SendBrokeredMessageAsync(game.DurationInMinutes, game.Id, "endgametime", (int)game.DurationInMinutes).Wait();
     }
     catch (Exception e)
     {
         analytic.TrackException(e);
     }
 }