/// <summary> /// Initialize the data source. Also ensures that the table exists. /// </summary> /// <param name="storageConnectionString">Storage connection string</param> /// <param name="tableName">Name of the table to connect to</param> /// <param name="usesIsDeleted">Set to FALSE for tables that do not have an IsDeleted field (i.e., external tables not created by this SDK)</param> public AzureTablesDataSource(string storageConnectionString, string tableName, bool usesIsDeleted = true) { if (string.IsNullOrWhiteSpace(storageConnectionString)) { throw new ArgumentNullException(nameof(storageConnectionString)); } if (string.IsNullOrWhiteSpace(tableName)) { throw new ArgumentNullException(nameof(tableName)); } StorageAccount = new AzureStorageAccount(storageConnectionString); CurrentTableName = tableName; UsesIsDeleted = usesIsDeleted; _currentTableClient = new CloudTableClient( StorageAccount.TableUri, new StorageCredentials(StorageAccount.AccountName, StorageAccount.AccountKey) ); _currentTableReference = _currentTableClient.GetTableReference(tableName); if (!_currentTableReference.Exists()) { _currentTableReference.Create(); } }
/// <summary> /// Instantiate the queue /// </summary> /// <param name="azureStorageAccount"></param> /// <param name="queueFlushInterval">Interval time in milliseconds between queue flushes (for eg: '1000' means the queue will be flushed once a second). /// Set longer values for queues that do not see much CRUD operations.</param> public OperationQueue(AzureStorageAccount azureStorageAccount, int queueFlushInterval = 1000) { tableClient = new CloudTableClient(azureStorageAccount.TableUri, new StorageCredentials(azureStorageAccount.AccountName, azureStorageAccount.AccountKey)); ResetQueueIndex(); __TIMER_PERIOD = queueFlushInterval; _processQueueTimer = new Timer(OnProcessQueueTimerElapsed, null, __TIMER_PERIOD, -1); }