private void LoadSettings(AzureStorageAccountSettings settings) { StorageSettings = settings; LoadSchemaMapping(StorageSettings.SchemaDefinition); try { AzureStorageAccount = CloudStorageAccount.Parse(settings.ConnectionString); AzureTableClient = AzureStorageAccount.CreateCloudTableClient(); StorageTable = AzureTableClient.GetTableReference(StorageSettings.TableName); } catch (Exception e) { throw new TelemetryReportingException("Unable to connect to the Azure Storage Table (" + e.Message + "). See InnerException for additional details.", e); } }
public static AWCloudTable GetTable(MSGorillaTable table) { if (_tableCache.ContainsKey(table)) { return(_tableCache[table]); } var client = AzureStorageAccount.CreateCloudTableClient(); CloudTable aztable = client.GetTableReference(_tableDict[table]); aztable.CreateIfNotExists(); CloudTable wosstable = null; if (WossStorageAccount != null) { client = WossStorageAccount.CreateCloudTableClient(); wosstable = client.GetTableReference(_tableDict[table]); DateTimeOffset startTime = DateTimeOffset.UtcNow; OperationContext opContext = new OperationContext(); try { wosstable.Create(null, opContext); } catch (Exception e) { if (!(e is StorageException && e.InnerException != null && e.InnerException.Message.Equals("The remote server returned an error: (409) Conflict."))) { Logger.Error(e, startTime, DateTime.Now, wosstable.Uri.ToString(), "CreateTable", opContext); } } } AWCloudTable awTable = new AWCloudTable(aztable, wosstable); _tableCache[table] = awTable; return(awTable); }