// combine properties to create final message that will be sent
        private static LogAnalyticsMessage MergeMessageProperties(LogAnalyticsMessage item, LogAnalyticsConfiguration config, LogAnalyticsAttribute attr)
        {
            var result = new LogAnalyticsMessage
            {
                Text = FirstOrDefault(item.Text, attr.Text),
                OperationsManagementWorkspace = FirstOrDefault(item.OperationsManagementWorkspace, attr.OperationsManagementWorkspace, config.OperationsManagementWorkspace),
                OperationsManagementKey       = FirstOrDefault(item.OperationsManagementKey, attr.OperationsManagementKey, config.OperationsManagementKey),
                LogName = FirstOrDefault(item.LogName, attr.LogName, config.LogName)
            };

            return(result);
        }
        public static async Task <string> WriteLogEntry(LogAnalyticsMessage mergedItem, LogAnalyticsAttribute attribute)
        {
            string result = string.Empty;

            try
            {
                // Create a hash for the API signature
                var    dateString   = DateTime.UtcNow.ToString("r");
                string stringToHash = "POST\n" + mergedItem.Text.Length + "\napplication/json\n" + "x-ms-date:" + dateString + "\n/api/logs";


                string hashedString = BuildSignature(stringToHash, attribute.OperationsManagementKey);

                string signature = "SharedKey " + attribute.OperationsManagementWorkspace + ":" + hashedString;

                result = await PostData(signature, attribute.OperationsManagementWorkspace, attribute.LogName, dateString, mergedItem.Text);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(result);
        }
 public LogAnalyticsAsyncCollector(LogAnalyticsConfiguration config, LogAnalyticsAttribute attr)
 {
     this.config = config;
     this.attr   = attr;
 }