// PRIVATE private void InitializeStorage() { var error = ""; try { // Open storage account using credentials from .cscfg file. // This is a common storage for the emails var storageAccount = CloudStorageAccount.Parse(TheSettingService.GetAzureStorageConnectionString()); // Get context object for working with queues, and // set a default retry policy appropriate for a web user interface. CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient(); //queueClient.DefaultRequestOptions.RetryPolicy = new LinearRetry(TimeSpan.FromSeconds(3), 3); var logQueueName = TheSettingService.GetAzureStorageLogQueueName(); if (!string.IsNullOrEmpty(logQueueName)) { _logQueue = queueClient.GetQueueReference(logQueueName); _logQueue.CreateIfNotExists(); } } catch (Exception ex) { /* Ignore for now */ ; } }
public override async Task ProcessLogMessage(LogMessage message) { // Create a new oms entity. OmsTableEntity oms = new OmsTableEntity(message.Tag); oms.LogLevel = message.Level.ToString(); oms.CorrelationId = message.CorrelationId; oms.Method = message.Method; oms.Message = message.Message; oms.LogType = message.Type.ToString(); oms.Duration = message.Duration; if (message.Properties != null) { string type = ""; string id = ""; string applicationType = ""; string applicationName = ""; string serviceType = ""; string serviceName = ""; string partitionId = ""; string replicationId = ""; string node = ""; message.Properties.TryGetValue(Constants.ServicePropType, out type); message.Properties.TryGetValue(Constants.ServicePropId, out id); message.Properties.TryGetValue(Constants.ServicePropApplicationType, out applicationType); message.Properties.TryGetValue(Constants.ServicePropApplicationName, out applicationName); message.Properties.TryGetValue(Constants.ServicePropServiceType, out serviceType); message.Properties.TryGetValue(Constants.ServicePropServiceName, out serviceName); message.Properties.TryGetValue(Constants.ServicePropPartitionId, out partitionId); message.Properties.TryGetValue(Constants.ServicePropReplicationId, out replicationId); message.Properties.TryGetValue(Constants.ServicePropNode, out node); oms.ContextType = type; oms.ContextId = id; oms.ApplicationType = applicationType; oms.ApplicationName = applicationName; oms.ServiceType = serviceType; oms.ServiceName = serviceName; oms.PartitionId = partitionId; oms.ReplicationId = replicationId; oms.Node = node; } // Not ideal to pass the connection string ...but the setting service is the only thing that have them await AzureStorageManager.Current.InsertIntoOmsStorage(oms, TheSettingService.GetAzureStorageConnectionString(), TheSettingService.GetAzureStorageLogsTable()); }