Пример #1
0
        private static void Main(string[] args)
        {
            using (var writer = Console.Out/*new StreamWriter(@"C:\temp\dumpling_deploy.log")*/)
            {
                writer.WriteLine("deploying dumpling service");
                var deployTasks = new[] {
                    DeployStateTable(writer),
                    DeployAnalysisTopic(writer),
                    DeployDataWorkerQueue(writer),
                    DeployEventHub(writer),
                    // StreamAnalytics is deployed via the Azure UI.
                    // classic webrole - deployed by an azure build process
                    // classic worker role - deployed by an azure build process
                    // todo: add storage deployment.
                };

                Task.WaitAll(deployTasks);
                writer.WriteLine("deployment completed successfully");
            }
        }
        public JsonResult RetrieveMessage(string queueName)
        {
            QueueClient queueClient = this.messagingFactory.CreateQueueClient(queueName, ReceiveMode.PeekLock);
            BrokeredMessage receivedMessage = queueClient.Receive(new TimeSpan(0, 0, 30));

            if (receivedMessage == null)
            {
                return this.Json(null, JsonRequestBehavior.AllowGet);
            }

            var receivedCustomMessage = receivedMessage.GetBody<CustomMessage>();

            var brokeredMsgProperties = new Dictionary<string, object>();
            brokeredMsgProperties.Add("Size", receivedMessage.Size);
            brokeredMsgProperties.Add("MessageId", receivedMessage.MessageId.Substring(0, 15) + "...");
            brokeredMsgProperties.Add("TimeToLive", receivedMessage.TimeToLive.TotalSeconds);
            brokeredMsgProperties.Add("EnqueuedTimeUtc", receivedMessage.EnqueuedTimeUtc.ToString("yyyy-MM-dd HH:mm:ss"));
            brokeredMsgProperties.Add("ExpiresAtUtc", receivedMessage.ExpiresAtUtc.ToString("yyyy-MM-dd HH:mm:ss"));

            var messageInfo = new
            {
                Label = receivedMessage.Label,
                Date = receivedCustomMessage.Date,
                Message = receivedCustomMessage.Body,
                Properties = receivedMessage.Properties.ToArray(),
                BrokeredMsgProperties = brokeredMsgProperties.ToArray()
            };

            receivedMessage.Complete();
            return this.Json(new { MessageInfo = messageInfo }, JsonRequestBehavior.AllowGet);
        }