Пример #1
0
        private static async Task ServiceBusOutput(Shared.Model.Message[] messages, StorageEndpointConfiguration configItem)
        {
            try
            {
                QueueClient queueClient = new QueueClient(configItem.ConnectionString, configItem.Name);

                List <Microsoft.Azure.ServiceBus.Message> serviceBusMessages = new List <Microsoft.Azure.ServiceBus.Message>();

                foreach (Syslog.Shared.Model.Message logMessage in messages)
                {
                    Microsoft.Azure.ServiceBus.Message serviceBusMessage = new Microsoft.Azure.ServiceBus.Message()
                    {
                        Body         = Encoding.UTF8.GetBytes(logMessage.MessageText),
                        MessageId    = logMessage.RowKey,
                        PartitionKey = logMessage.PartitionKey,
                    };

                    serviceBusMessage.UserProperties.Add("SourceIP", logMessage.SourceIP);
                    serviceBusMessage.UserProperties.Add("RecvTime", logMessage.RecvTime);

                    serviceBusMessages.Add(serviceBusMessage);
                }

                await queueClient.SendAsync(serviceBusMessages);
            }
            catch (Exception ex)
            {
                if (Program.telemetryClient != null)
                {
                    Program.telemetryClient.TrackException(ex);
                }

                Console.WriteLine("An error occured: " + ex.Message);
            }
        }
Пример #2
0
        private static async Task TableOutput(Shared.Model.Message[] messages, StorageEndpointConfiguration configItem)
        {
            TableStorageAdapter tableStorageAdapter = new TableStorageAdapter(configItem.ConnectionString);

            await tableStorageAdapter.ExcuteBatchOperationToTable(configItem.Name, messages).ConfigureAwait(false);
        }