Here are the examples of the csharp api Microsoft.WindowsAzure.Storage.Table.CloudTableClient.GetTableReference(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
71 Examples
19
Source : StorageManagerTests.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
[Fact]
public async Task ExecuteRetrieval_ReturnsNotFound_IfInvalidTable()
{
// Arrange
var storageAccount = CloudStorageAccount.Parse("UseDevelopmentStorage=true;");
var client = storageAccount.CreateCloudTableClient();
var table = client.GetTableReference("unknown");
// Act
var actual = await _manager.ExecuteRetrievalAsync(table, TestParreplacedion, "data");
// replacedert
replacedert.Equal(404, actual.HttpStatusCode);
}
19
Source : StorageManager.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
public CloudTable GetCloudTable(string connectionString, string tableName)
{
if (connectionString == null)
{
throw new ArgumentNullException(nameof(connectionString));
}
if (tableName == null)
{
throw new ArgumentNullException(nameof(tableName));
}
var tableKey = GetLookupKey(connectionString, tableName);
var account = TableAccounts.GetOrAdd(
tableKey,
key =>
{
var storageAccount = GetCloudStorageAccount(connectionString);
try
{
// Ensure that table exists
var client = storageAccount.CreateCloudTableClient();
var cloudTable = client.GetTableReference(tableName);
cloudTable.CreateIfNotExists();
}
catch (Exception ex)
{
var error = GetStorageErrorMessage(ex);
var message = string.Format(CultureInfo.CurrentCulture, AzureStorageResources.StorageManager_InitializationFailure, error);
_logger.Error(message, ex);
throw new InvalidOperationException(message, ex);
}
return storageAccount;
});
var cloudClient = account.CreateCloudTableClient();
return cloudClient.GetTableReference(tableName);
}
19
Source : StorageService.cs
with MIT License
from Azure
with MIT License
from Azure
public async Task<List<DiagEnreplacedy>> GetEnreplacediesByParreplacedionkey(string parreplacedionKey = null, DateTime? startTime = null)
{
int retryThreshold = 2;
int attempt = 0;
var detectorsResult = new List<DiagEnreplacedy>();
do
{
var clientRequestId = Guid.NewGuid().ToString();
try
{
CloudTable table = tableClient.GetTableReference(tableName);
var timeTakenStopWatch = new Stopwatch();
if (string.IsNullOrWhiteSpace(parreplacedionKey))
{
parreplacedionKey = "Detector";
}
var filterParreplacedionKey = TableQuery.GenerateFilterCondition(ParreplacedionKey, QueryComparisons.Equal, parreplacedionKey);
DateTime timeFilter = startTime ?? DateTime.MinValue;
string timestampFilter = TableQuery.GenerateFilterConditionForDate("Timestamp", QueryComparisons.GreaterThanOrEqual, new DateTimeOffset(timeFilter));
string finalFilter = timeFilter.Equals(DateTime.MinValue) ? filterParreplacedionKey : TableQuery.CombineFilters(filterParreplacedionKey, TableOperators.And, timestampFilter);
var tableQuery = new TableQuery<DiagEnreplacedy>();
tableQuery.Where(finalFilter);
TableContinuationToken tableContinuationToken = null;
timeTakenStopWatch.Start();
TableRequestOptions tableRequestOptions = new TableRequestOptions();
tableRequestOptions.LocationMode = LocationMode.PrimaryThenSecondary;
tableRequestOptions.MaximumExecutionTime = TimeSpan.FromSeconds(30);
OperationContext oc = new OperationContext();
oc.ClientRequestID = clientRequestId;
if (attempt == retryThreshold)
{
tableRequestOptions.LocationMode = LocationMode.SecondaryOnly;
DiagnosticsETWProvider.Instance.LogAzureStorageMessage(nameof(StorageService), $"Retrying table against secondary account after {attempt} attempts");
}
do
{
DiagnosticsETWProvider.Instance.LogAzureStorageMessage(nameof(StorageService), $"Querying against {tableName} with Client Request id {oc.ClientRequestID}");
// Execute the operation.
var detectorList = await table.ExecuteQuerySegmentedAsync(tableQuery, tableContinuationToken, tableRequestOptions, null);
tableContinuationToken = detectorList.ContinuationToken;
if (detectorList.Results != null)
{
detectorsResult.AddRange(detectorList.Results);
}
} while (tableContinuationToken != null);
timeTakenStopWatch.Stop();
DiagnosticsETWProvider.Instance.LogAzureStorageMessage(nameof(StorageService), $"GetEnreplacedies by Parreplacedion key {parreplacedionKey} took {timeTakenStopWatch.ElapsedMilliseconds}, Total rows = {detectorsResult.Count}, ClientRequestId = {clientRequestId} ");
return startTime == DateTime.MinValue ? detectorsResult.Where(result => !result.IsDisabled).ToList() :
detectorsResult.ToList();
}
catch (Exception ex)
{
DiagnosticsETWProvider.Instance.LogAzureStorageException(nameof(StorageService), $"ClientRequestId : {clientRequestId} {ex.Message}", ex.GetType().ToString(), ex.ToString());
}
finally
{
attempt++;
}
} while (attempt <= retryThreshold);
return detectorsResult;
}
19
Source : StorageService.cs
with MIT License
from Azure
with MIT License
from Azure
public async Task<DetectorRuntimeConfiguration> LoadConfiguration(DetectorRuntimeConfiguration configuration)
{
var clientRequestId = Guid.NewGuid().ToString();
try
{
// Create a table client for interacting with the table service
CloudTable table = tableClient.GetTableReference(detectorRuntimeConfigTable);
if (configuration == null || configuration.ParreplacedionKey == null || configuration.RowKey == null)
{
throw new ArgumentNullException(nameof(configuration));
}
DiagnosticsETWProvider.Instance.LogAzureStorageMessage(nameof(StorageService), $"Insert or Replace {configuration.RowKey} into {detectorRuntimeConfigTable} ClientRequestId {clientRequestId}");
var timeTakenStopWatch = new Stopwatch();
timeTakenStopWatch.Start();
// Create the InsertOrReplace table operation
TableOperation insertOrReplaceOperation = TableOperation.InsertOrReplace(configuration);
TableRequestOptions tableRequestOptions = new TableRequestOptions();
tableRequestOptions.LocationMode = LocationMode.PrimaryOnly;
tableRequestOptions.MaximumExecutionTime = TimeSpan.FromSeconds(60);
OperationContext oc = new OperationContext();
oc.ClientRequestID = clientRequestId;
// Execute the operation.
TableResult result = await table.ExecuteAsync(insertOrReplaceOperation, tableRequestOptions, oc);
timeTakenStopWatch.Stop();
DiagnosticsETWProvider.Instance.LogAzureStorageMessage(nameof(StorageService), $"InsertOrReplace result : {result.HttpStatusCode}, time taken {timeTakenStopWatch.ElapsedMilliseconds} ClientRequestId {clientRequestId}");
DetectorRuntimeConfiguration insertedRow = result.Result as DetectorRuntimeConfiguration;
return insertedRow;
}
catch (Exception ex)
{
DiagnosticsETWProvider.Instance.LogAzureStorageException(nameof(StorageService), $"ClientRequestId {clientRequestId} {ex.Message}", ex.GetType().ToString(), ex.ToString());
return null;
}
}
19
Source : StorageService.cs
with MIT License
from Azure
with MIT License
from Azure
public async Task<DiagEnreplacedy> LoadDataToTable(DiagEnreplacedy detectorEnreplacedy)
{
var clientRequestId = Guid.NewGuid().ToString();
try
{
// Create a table client for interacting with the table service
CloudTable table = tableClient.GetTableReference(tableName);
if (detectorEnreplacedy == null || detectorEnreplacedy.ParreplacedionKey == null || detectorEnreplacedy.RowKey == null)
{
throw new ArgumentNullException(nameof(detectorEnreplacedy));
}
var timeTakenStopWatch = new Stopwatch();
timeTakenStopWatch.Start();
// Create the InsertOrReplace table operation
TableOperation insertOrReplaceOperation = TableOperation.InsertOrReplace(detectorEnreplacedy);
TableRequestOptions tableRequestOptions = new TableRequestOptions();
tableRequestOptions.LocationMode = LocationMode.PrimaryOnly;
tableRequestOptions.MaximumExecutionTime = TimeSpan.FromSeconds(60);
OperationContext oc = new OperationContext();
oc.ClientRequestID = clientRequestId;
// Execute the operation.
DiagnosticsETWProvider.Instance.LogAzureStorageMessage(nameof(StorageService), $"Insert or Replace {detectorEnreplacedy.RowKey} into {tableName} ClientRequestId {clientRequestId}");
TableResult result = await table.ExecuteAsync(insertOrReplaceOperation, tableRequestOptions, oc);
timeTakenStopWatch.Stop();
DiagnosticsETWProvider.Instance.LogAzureStorageMessage(nameof(StorageService), $"InsertOrReplace result : {result.HttpStatusCode}, time taken {timeTakenStopWatch.ElapsedMilliseconds}, ClientRequestId {clientRequestId}");
DiagEnreplacedy insertedEnreplacedy = result.Result as DiagEnreplacedy;
return detectorEnreplacedy;
}
catch (Exception ex)
{
DiagnosticsETWProvider.Instance.LogAzureStorageException(nameof(StorageService), $"ClientRequestId {clientRequestId} {ex.Message}", ex.GetType().ToString(), ex.ToString());
return null;
}
}
19
Source : StorageService.cs
with MIT License
from Azure
with MIT License
from Azure
public async Task<List<DetectorRuntimeConfiguration>> GetKustoConfiguration()
{
var clientRequestId = Guid.NewGuid().ToString();
try
{
CloudTable cloudTable = tableClient.GetTableReference(detectorRuntimeConfigTable);
var timeTakenStopWatch = new Stopwatch();
var parreplacedionkey = "KustoClusterMapping";
var filterParreplacedionKey = TableQuery.GenerateFilterCondition(ParreplacedionKey, QueryComparisons.Equal, parreplacedionkey);
var tableQuery = new TableQuery<DetectorRuntimeConfiguration>();
tableQuery.Where(filterParreplacedionKey);
TableContinuationToken tableContinuationToken = null;
var diagConfigurationsResult = new List<DetectorRuntimeConfiguration>();
timeTakenStopWatch.Start();
do
{
// Execute the operation.
TableRequestOptions tableRequestOptions = new TableRequestOptions();
tableRequestOptions.LocationMode = LocationMode.PrimaryThenSecondary;
tableRequestOptions.MaximumExecutionTime = TimeSpan.FromSeconds(30);
OperationContext oc = new OperationContext();
oc.ClientRequestID = clientRequestId;
DiagnosticsETWProvider.Instance.LogAzureStorageMessage(nameof(StorageService), $"Querying against table {detectorRuntimeConfigTable} with ClientRequestId {clientRequestId}");
var diagConfigurations = await cloudTable.ExecuteQuerySegmentedAsync(tableQuery, tableContinuationToken, tableRequestOptions, oc);
tableContinuationToken = diagConfigurations.ContinuationToken;
if (diagConfigurations.Results != null)
{
diagConfigurationsResult.AddRange(diagConfigurations.Results);
}
} while (tableContinuationToken != null);
timeTakenStopWatch.Stop();
DiagnosticsETWProvider.Instance.LogAzureStorageMessage(nameof(StorageService), $"GetConfiguration by Parreplacedion key {parreplacedionkey} took {timeTakenStopWatch.ElapsedMilliseconds}, Total rows = {diagConfigurationsResult.Count} ClientRequestId {clientRequestId}");
return diagConfigurationsResult.Where(row => !row.IsDisabled).ToList();
}
catch (Exception ex)
{
DiagnosticsETWProvider.Instance.LogAzureStorageException(nameof(StorageService), $"ClientRequestId {clientRequestId} {ex.Message}", ex.GetType().ToString(), ex.ToString());
return null;
}
}
19
Source : StorageService.cs
with MIT License
from Azure
with MIT License
from Azure
public async Task LoadBatchDataToTable(List<DiagEnreplacedy> diagEnreplacedies)
{
var clientRequestId = Guid.NewGuid().ToString();
try
{
// Create a table reference for interacting with the table service
CloudTable table = tableClient.GetTableReference(tableName);
if (diagEnreplacedies == null || diagEnreplacedies.Count == 0)
{
throw new ArgumentNullException("List is empty");
}
var timeTakenStopWatch = new Stopwatch();
timeTakenStopWatch.Start();
TableBatchOperation batchOperation = new TableBatchOperation();
foreach (var enreplacedy in diagEnreplacedies)
{
batchOperation.InsertOrReplace(enreplacedy);
}
TableRequestOptions tableRequestOptions = new TableRequestOptions();
tableRequestOptions.LocationMode = LocationMode.PrimaryOnly;
tableRequestOptions.MaximumExecutionTime = TimeSpan.FromSeconds(60);
OperationContext oc = new OperationContext();
oc.ClientRequestID = clientRequestId;
DiagnosticsETWProvider.Instance.LogAzureStorageMessage(nameof(StorageService), $"Insert or Replace batch diag enreplacedies into {tableName} ClientRequestId {clientRequestId}");
//Execute batch operation
IList<TableResult> result = await table.ExecuteBatchAsync(batchOperation, tableRequestOptions, oc);
timeTakenStopWatch.Stop();
DiagnosticsETWProvider.Instance.LogAzureStorageMessage(nameof(StorageService), $"InsertOrReplace batch time taken {timeTakenStopWatch.ElapsedMilliseconds}, ClientRequestId {clientRequestId}");
}
catch (Exception ex)
{
DiagnosticsETWProvider.Instance.LogAzureStorageException(nameof(StorageService), $"ClientRequestId {clientRequestId} {ex.Message}", ex.GetType().ToString(), ex.ToString());
throw;
}
}
19
Source : IStorageService.cs
with MIT License
from Azure
with MIT License
from Azure
public async Task<DiagEnreplacedy> LoadDataToTable(DiagEnreplacedy detectorEnreplacedy, string dirname)
{
try {
// Create a table client for interacting with the table service
CloudTable table = tableClient.GetTableReference(tableName);
if(detectorEnreplacedy == null || detectorEnreplacedy.ParreplacedionKey == null || detectorEnreplacedy.RowKey == null)
{
storageServiceLogger.LogError($"Parition key or row key is empty for github directory {dirname}");
throw new ArgumentNullException(nameof(detectorEnreplacedy));
}
storageServiceLogger.LogInformation($"Insert or Replace {detectorEnreplacedy.RowKey} into {tableName}");
// Create the InsertOrReplace table operation
TableOperation insertOrReplaceOperation = TableOperation.InsertOrReplace(detectorEnreplacedy);
// Execute the operation.
TableResult result = await table.ExecuteAsync(insertOrReplaceOperation);
storageServiceLogger.LogInformation($"InsertOrReplace result : {result.HttpStatusCode}");
var insertedEnreplacedy = result.Result as DiagEnreplacedy;
return detectorEnreplacedy;
}
catch (Exception ex)
{
storageServiceLogger.LogError(ex.ToString());
return null;
}
}
19
Source : IStorageService.cs
with MIT License
from Azure
with MIT License
from Azure
public async Task<DiagEnreplacedy> GetEnreplacedyFromTable(string parreplacedionKey, string rowKey, string dirname)
{
try
{
CloudTable table = tableClient.GetTableReference(tableName);
if(string.IsNullOrWhiteSpace(parreplacedionKey) || string.IsNullOrWhiteSpace(rowKey))
{
throw new ArgumentNullException($"{nameof(parreplacedionKey)} or {nameof(rowKey)} is either null or empty for githubdir {dirname}");
}
storageServiceLogger.LogInformation($"Retrieving info from table for {rowKey}, {parreplacedionKey}");
TableOperation retrieveOperation = TableOperation.Retrieve<DiagEnreplacedy>(parreplacedionKey, rowKey);
// Execute the operation.
TableResult result = await table.ExecuteAsync(retrieveOperation);
var existingEnreplacedy = result.Result as DiagEnreplacedy;
return existingEnreplacedy;
} catch (Exception ex)
{
storageServiceLogger.LogError(ex.ToString());
return null;
}
}
19
Source : IStorageService.cs
with MIT License
from Azure
with MIT License
from Azure
public async Task<List<DiagEnreplacedy>> GetAllEnreplacedies()
{
try
{
CloudTable table = tableClient.GetTableReference(tableName);
storageServiceLogger.LogInformation($"Retrieving all rows from {tableName}");
var detectorFilter = TableQuery.GenerateFilterCondition(ParreplacedionKey, QueryComparisons.Equal, "Detector");
var gistFilter = TableQuery.GenerateFilterCondition(ParreplacedionKey, QueryComparisons.Equal, "Gist");
var combinedFilter = TableQuery.CombineFilters(detectorFilter, TableOperators.Or, gistFilter);
var tableQuery = new TableQuery<DiagEnreplacedy>();
tableQuery.Where(combinedFilter);
TableContinuationToken tableContinuationToken = null;
var allRows = new List<DiagEnreplacedy>();
do
{
// Execute the operation.
var detectorList = await table.ExecuteQuerySegmentedAsync(tableQuery, tableContinuationToken);
tableContinuationToken = detectorList.ContinuationToken;
if (detectorList.Results != null)
{
allRows.AddRange(detectorList.Results);
}
} while (tableContinuationToken != null);
return allRows;
}
catch (Exception ex)
{
storageServiceLogger.LogError(ex.ToString());
return null;
}
}
19
Source : SDKWrapper.cs
with MIT License
from Azure
with MIT License
from Azure
public async Task<CloudTable> GetTableReferenceAsync(CloudTableClient tableClient, Config storageConfig)
{
var table = tableClient.GetTableReference(storageConfig.TableStorageTableName);
await table.CreateIfNotExistsAsync();
return table;
}
19
Source : Orchestrator.cs
with MIT License
from Azure-Samples
with MIT License
from Azure-Samples
[FunctionName("SaveRepositories")]
public static async Task SaveRepositories([ActivityTrigger] IDurableActivityContext context)
{
// retrieves a tuple from the Orchestrator function
var parameters = context.GetInput<List<(long id, int openedIssues, string name)>>();
// create the client and table reference for Blob Storage
var client = account.CreateCloudTableClient();
var table = client.GetTableReference("Repositories");
// create the table if it doesn't exist already.
await table.CreateIfNotExistsAsync();
// creates a batch of operation to be executed
var batchOperation = new TableBatchOperation();
foreach (var parameter in parameters)
{
// Creates an operation to add the repository to Table Storage
batchOperation.Add(TableOperation.InsertOrMerge(new Repository(parameter.id)
{
OpenedIssues = parameter.openedIssues,
RepositoryName = parameter.name
}));
}
await table.ExecuteBatchAsync(batchOperation);
}
19
Source : Helpers.cs
with MIT License
from Azure-Samples
with MIT License
from Azure-Samples
public static async System.Threading.Tasks.Task<CloudTable> GetLockTableAsync(CloudStorageAccount storageAccount = null)
{
CloudTable customerFilesTable;
if (storageAccount == null)
{
if (!CloudStorageAccount.TryParse(Environment.GetEnvironmentVariable(@"AzureWebJobsStorage"), out var sa))
{
throw new Exception(@"Can't create a storage account accessor from app setting connection string, sorry!");
}
else
{
storageAccount = sa;
}
}
try
{
customerFilesTable = storageAccount.CreateCloudTableClient().GetTableReference(@"FileProcessingLocks");
}
catch (Exception ex)
{
throw new Exception($@"Error creating table client for locks: {ex}", ex);
}
while (true)
{
try
{
await customerFilesTable.CreateIfNotExistsAsync();
break;
}
catch { }
}
return customerFilesTable;
}
19
Source : Program.cs
with Apache License 2.0
from bmaluijb
with Apache License 2.0
from bmaluijb
public void Run(CloudTableClient tableClient, int numIterations)
{
Console.WriteLine("\n");
Console.WriteLine("Creating Table if it doesn't exist...");
CloudTable table = tableClient.GetTableReference("People");
table.DeleteIfExists();
table.CreateIfNotExists();
List<CustomerEnreplacedy> items = new List<CustomerEnreplacedy>();
Stopwatch watch = new Stopwatch();
Console.WriteLine("\n");
Console.WriteLine("Running inserts: ");
for (int i = 0; i < numIterations; i++)
{
watch.Start();
CustomerEnreplacedy item = new CustomerEnreplacedy()
{
ParreplacedionKey = Guid.NewGuid().ToString(),
RowKey = Guid.NewGuid().ToString(),
Email = $"{GetRandomString(6)}@contoso.com",
PhoneNumber = "425-555-0102",
Bio = GetRandomString(1000)
};
TableOperation insertOperation = TableOperation.Insert(item);
table.Execute(insertOperation);
double latencyInMs = watch.Elapsed.TotalMilliseconds;
Console.Write($"\r\tInsert #{i + 1} completed in {latencyInMs} ms.");
items.Add(item);
watch.Reset();
}
Console.WriteLine("\n");
Console.WriteLine("Running retrieves: ");
for (int i = 0; i < numIterations; i++)
{
watch.Start();
TableOperation retrieveOperation = TableOperation.Retrieve<CustomerEnreplacedy>(items[i].ParreplacedionKey, items[i].RowKey);
table.Execute(retrieveOperation);
double latencyInMs = watch.Elapsed.TotalMilliseconds;
Console.Write($"\r\tRetrieve #{i + 1} completed in {latencyInMs} ms");
watch.Reset();
}
Console.WriteLine("\n");
Console.WriteLine("Running replace: ");
for (int i = 0; i < numIterations; i++)
{
watch.Start();
// Same latency as inserts, p99 < 15ms, and p50 < 6ms
items[i].PhoneNumber = "425-555-5555";
TableOperation replaceOperation = TableOperation.Replace(items[i]);
table.Execute(replaceOperation);
double latencyInMs = watch.Elapsed.TotalMilliseconds;
Console.Write($"\r\tReplace #{i + 1} completed in {latencyInMs} ms");
watch.Reset();
}
}
19
Source : TableBotDataStore2.cs
with MIT License
from microsoft
with MIT License
from microsoft
private CloudTable GetTable(IAddress key)
{
string tableName = $"bd{key.BotId}{key.ChannelId}".SanitizeTableName();
lock (tables)
{
CloudTable table;
if (tables.TryGetValue(tableName, out table))
return table;
table = tableClient.GetTableReference(tableName);
table.CreateIfNotExists();
tables.Add(tableName, table);
return table;
}
}
19
Source : TableLogger.cs
with MIT License
from microsoft
with MIT License
from microsoft
protected override void Load(ContainerBuilder builder)
{
base.Load(builder);
builder.RegisterInstance(_account)
.replacedelf();
builder.Register(c => c.Resolve<CloudStorageAccount>().CreateCloudTableClient())
.replacedelf()
.SingleInstance();
builder.Register(c =>
{
var table = c.Resolve<CloudTableClient>().GetTableReference(_tableName);
table.CreateIfNotExists();
return table;
})
.replacedelf()
.SingleInstance();
builder.RegisterType<TableLogger>()
.AsImplementedInterfaces()
.SingleInstance();
}
19
Source : TableDataStoreTests.cs
with MIT License
from microsoft
with MIT License
from microsoft
public override IBotDataStore<BotData> GetTestCaseDataStore()
{
var tableName = "TableBotDataTest";
var account = CloudStorageAccount.DevelopmentStorageAccount;
var table = account.CreateCloudTableClient().GetTableReference(tableName);
table.DeleteIfExists();
table.CreateIfNotExists();
return new TableBotDataStore(table);
}
19
Source : LoggerTests.cs
with MIT License
from microsoft
with MIT License
from microsoft
[TestMethod]
[TestCategory("Azure")]
// NOTE: To run this test you must have installed the Azure Storage Emulator.
// You can download it here: https://go.microsoft.com/fwlink/?linkid=717179&clcid=0x409
// The test will automatically start the emulator.
public async Task TableLoggerTest()
{
var tableName = "TableLoggerTestActivities";
var account = CloudStorageAccount.DevelopmentStorageAccount;
account.CreateCloudTableClient().GetTableReference(tableName).DeleteIfExists();
var builder = new ContainerBuilder();
builder.RegisterModule(new TableLoggerModule(account, tableName));
var container = builder.Build();
var logger = container.Resolve<IActivityLogger>();
var source = container.Resolve<IActivitySource>();
var manager = container.Resolve<IActivityManager>();
var activities = GetTestActivityList();
var comparator = new CompareActivity();
for (var i = 0; i < activities.Count; ++i)
{
await logger.LogAsync(activities[i]);
var oldest = LastActivity.AddSeconds(-30);
replacedertEqual(Filter(activities, oldest: oldest, take: i + 1), source.Activities(DefaultChannel, DefaultConversation, oldest));
}
var conversation = Filter(activities);
replacedertEqual(conversation, source.Activities(DefaultChannel, DefaultConversation));
replacedertEqual(Filter(activities, channel: "channel2"), source.Activities("channel2", "conversation1"));
replacedertEqual(Filter(activities, conversation: "conversation2"), source.Activities(DefaultChannel, "conversation2"));
var transcript = new List<string>();
foreach (var activity in conversation)
{
var msg = activity as IMessageActivity;
if (msg != null)
{
transcript.Add($"({msg.From.Name} {msg.Timestamp:g})");
transcript.Add($"{msg.Text}");
}
}
int j = 0;
var botToUser = new Mock<IBotToUser>();
botToUser
.Setup(p => p.PostAsync(It.IsAny<IMessageActivity>(), It.IsAny<CancellationToken>()))
.Returns(Task.CompletedTask)
.Callback((IMessageActivity activity, CancellationToken cancel) =>
replacedert.AreEqual(transcript[j++], activity.Text));
botToUser
.Setup(p => p.MakeMessage())
.Returns(new Activity());
var replay = new ReplayTranscript(botToUser.Object);
await source.WalkActivitiesAsync(replay.Replay, DefaultChannel, DefaultConversation);
await manager.DeleteConversationAsync(DefaultChannel, "conversation2");
replacedert.AreEqual(0, source.Activities(DefaultChannel, "conversation2").Count());
await manager.DeleteConversationAsync("channel2", DefaultConversation);
replacedert.AreEqual(0, source.Activities("channel2", DefaultConversation).Count());
await manager.DeleteUserActivitiesAsync("user2");
await source.WalkActivitiesAsync(activity =>
{
replacedert.IsTrue(activity.From.Id != "user2" && activity.Recipient.Id != "user2");
return Task.CompletedTask;
});
var purge = LastActivity.AddSeconds(-30.0);
await manager.DeleteBeforeAsync(purge);
replacedertEqual(Filter(activities, oldest: purge), source.Activities(DefaultChannel, DefaultConversation));
}
19
Source : FavoriteStorageProvider.cs
with MIT License
from OfficeDev
with MIT License
from OfficeDev
private async Task InitializeAsync(string connectionString)
{
// Exponential retry policy with backoff of 3 seconds and 5 retries.
var exponentialRetryPolicy = new TableRequestOptions()
{
RetryPolicy = new ExponentialRetry(TimeSpan.FromSeconds(3), 5),
};
try
{
var storageAccount = CloudStorageAccount.Parse(connectionString);
this.cloudTableClient = storageAccount.CreateCloudTableClient();
this.cloudTableClient.DefaultRequestOptions = exponentialRetryPolicy;
this.cloudTable = this.cloudTableClient.GetTableReference(TableName);
await this.cloudTable.CreateIfNotExistsAsync().ConfigureAwait(false);
}
catch (Exception ex)
{
this.telemetryClient.TrackException(ex);
throw;
}
}
19
Source : ActivityStorageProvider.cs
with MIT License
from OfficeDev
with MIT License
from OfficeDev
private async Task InitializeAsync(string connectionString)
{
try
{
var storageAccount = CloudStorageAccount.Parse(connectionString);
this.cloudTableClient = storageAccount.CreateCloudTableClient();
this.cloudTable = this.cloudTableClient.GetTableReference(TableName);
await this.cloudTable.CreateIfNotExistsAsync().ConfigureAwait(false);
}
catch (Exception ex)
{
this.telemetryClient.TrackException(ex);
throw;
}
}
19
Source : UserConfigurationStorageProvider.cs
with MIT License
from OfficeDev
with MIT License
from OfficeDev
private async Task InitializeAsync(string connectionString)
{
try
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
this.cloudTableClient = storageAccount.CreateCloudTableClient();
this.cloudTable = this.cloudTableClient.GetTableReference(TableName);
await this.cloudTable.CreateIfNotExistsAsync().ConfigureAwait(false);
}
catch (Exception ex)
{
this.telemetryClient.TrackException(ex);
throw;
}
}
19
Source : BaseStorageProvider.cs
with MIT License
from OfficeDev
with MIT License
from OfficeDev
private async Task<CloudTable> InitializeAsync()
{
// Exponential retry policy with back off of 1 seconds and 3 retries.
var exponentialRetryPolicy = new TableRequestOptions()
{
RetryPolicy = new ExponentialRetry(TimeSpan.FromSeconds(1), 3),
};
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(this.connectionString);
CloudTableClient cloudTableClient = storageAccount.CreateCloudTableClient();
cloudTableClient.DefaultRequestOptions = exponentialRetryPolicy;
this.DlLookupCloudTable = cloudTableClient.GetTableReference(this.TableName);
await this.DlLookupCloudTable.CreateIfNotExistsAsync();
return this.DlLookupCloudTable;
}
19
Source : ConfigurationStorageProvider.cs
with MIT License
from OfficeDev
with MIT License
from OfficeDev
private async Task<CloudTable> InitializeAsync(string connectionString)
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
this.cloudTableClient = storageAccount.CreateCloudTableClient();
this.configurationCloudTable = this.cloudTableClient.GetTableReference(CrowdSourcerTableName);
if (!await this.configurationCloudTable.ExistsAsync())
{
await this.configurationCloudTable.CreateIfNotExistsAsync();
}
return this.configurationCloudTable;
}
19
Source : ObjectIdToNameMapper.cs
with MIT License
from OfficeDev
with MIT License
from OfficeDev
private async Task<CloudTable> InitializeAsync(string connectionString)
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
this.cloudTableClient = storageAccount.CreateCloudTableClient();
this.configurationCloudTable = this.cloudTableClient.GetTableReference(NameIdMappingTableName);
if (!await this.configurationCloudTable.ExistsAsync())
{
await this.configurationCloudTable.CreateIfNotExistsAsync();
}
return this.configurationCloudTable;
}
19
Source : UserProfileActivityStorageHelper.cs
with MIT License
from OfficeDev
with MIT License
from OfficeDev
private async Task InitializeAsync()
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(this.connectionString);
CloudTableClient cloudTableClient = storageAccount.CreateCloudTableClient();
this.profileCloudTable = cloudTableClient.GetTableReference(this.tableName);
await this.profileCloudTable.CreateIfNotExistsAsync().ConfigureAwait(false);
}
19
Source : ActivityStorageProvider.cs
with MIT License
from OfficeDev
with MIT License
from OfficeDev
private async Task<CloudTable> InitializeAsync(string connectionString)
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
this.cloudTableClient = storageAccount.CreateCloudTableClient();
this.cloudTable = this.cloudTableClient.GetTableReference(ActivityTableName);
if (!await this.cloudTable.ExistsAsync().ConfigureAwait(false))
{
await this.cloudTable.CreateIfNotExistsAsync().ConfigureAwait(false);
}
return this.cloudTable;
}
19
Source : ConfigurationDataProvider.cs
with MIT License
from OfficeDev
with MIT License
from OfficeDev
private async Task InitializeAsync(string connectionString)
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
CloudTableClient cloudTableClient = storageAccount.CreateCloudTableClient();
this.configurationCloudTable = cloudTableClient.GetTableReference(ConfigurationTableName);
await this.configurationCloudTable.CreateIfNotExistsAsync().ConfigureAwait(false);
}
19
Source : HelpDataProvider.cs
with MIT License
from OfficeDev
with MIT License
from OfficeDev
private async Task InitializeTableAsync(string connectionString)
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
CloudTableClient cloudTableClient = storageAccount.CreateCloudTableClient();
this.helpInfoCloudTable = cloudTableClient.GetTableReference(StorageInfo.HelpInfoTableName);
await this.helpInfoCloudTable.CreateIfNotExistsAsync();
}
19
Source : TicketsProvider.cs
with MIT License
from OfficeDev
with MIT License
from OfficeDev
private async Task InitializeTableStorageAsync(string connectionString)
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
CloudTableClient cloudTableClient = storageAccount.CreateCloudTableClient();
this.ticketCloudTable = cloudTableClient.GetTableReference(Constants.TicketTableName);
await this.ticketCloudTable.CreateIfNotExistsAsync().ConfigureAwait(false);
}
19
Source : StorageInitializationHelper.cs
with MIT License
from OfficeDev
with MIT License
from OfficeDev
private async Task<CloudTable> InitializeAsync()
{
// Exponential retry policy with back off set to 3 seconds and 5 retries.
var exponentialRetryPolicy = new TableRequestOptions()
{
RetryPolicy = new ExponentialRetry(TimeSpan.FromSeconds(3), 5),
};
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(this.connectionString);
this.cloudTableClient = storageAccount.CreateCloudTableClient();
this.cloudTableClient.DefaultRequestOptions = exponentialRetryPolicy;
this.cloudTable = this.cloudTableClient.GetTableReference(this.tableName);
if (!await this.cloudTable.ExistsAsync())
{
await this.cloudTable.CreateIfNotExistsAsync();
}
return this.cloudTable;
}
19
Source : TicketsProvider.cs
with MIT License
from OfficeDev
with MIT License
from OfficeDev
private async Task InitializeAsync(string connectionString)
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
CloudTableClient cloudTableClient = storageAccount.CreateCloudTableClient();
this.ticketCloudTable = cloudTableClient.GetTableReference(StorageInfo.TicketTableName);
await this.ticketCloudTable.CreateIfNotExistsAsync();
}
19
Source : StorageBaseProvider.cs
with MIT License
from OfficeDev
with MIT License
from OfficeDev
private async Task<CloudTable> InitializeAsync()
{
// Exponential retry policy with back off set to 3 seconds and 5 retries.
var exponentialRetryPolicy = new TableRequestOptions()
{
RetryPolicy = new ExponentialRetry(TimeSpan.FromSeconds(3), 5),
};
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(this.connectionString);
this.cloudTableClient = storageAccount.CreateCloudTableClient();
this.cloudTableClient.DefaultRequestOptions = exponentialRetryPolicy;
this.CloudTable = this.cloudTableClient.GetTableReference(this.tableName);
await this.CloudTable.CreateIfNotExistsAsync();
return this.CloudTable;
}
19
Source : BaseStorageProvider.cs
with MIT License
from OfficeDev
with MIT License
from OfficeDev
private async Task<CloudTable> InitializeAsync()
{
// Exponential retry policy with back off of 0.5 seconds and 3 retries.
var exponentialRetryPolicy = new TableRequestOptions()
{
RetryPolicy = new ExponentialRetry(TimeSpan.FromSeconds(0.5), 3),
};
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(this.connectionString);
CloudTableClient cloudTableClient = storageAccount.CreateCloudTableClient();
cloudTableClient.DefaultRequestOptions = exponentialRetryPolicy;
this.CloudTable = cloudTableClient.GetTableReference(this.TableName);
await this.CloudTable.CreateIfNotExistsAsync();
return this.CloudTable;
}
19
Source : BaseStorageProvider.cs
with MIT License
from OfficeDev
with MIT License
from OfficeDev
private async Task InitializeAsync()
{
try
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(this.connectionString);
CloudTableClient cloudTableClient = storageAccount.CreateCloudTableClient();
this.CloudTable = cloudTableClient.GetTableReference(this.TableName);
await this.CloudTable.CreateIfNotExistsAsync();
}
catch (Exception ex)
{
this.logger.LogError(ex, "Error occurred while creating the table.");
throw;
}
}
19
Source : ConfigurationProvider.cs
with MIT License
from OfficeDev
with MIT License
from OfficeDev
private async Task InitializeAsync(string connectionString)
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
CloudTableClient cloudTableClient = storageAccount.CreateCloudTableClient();
this.configurationCloudTable = cloudTableClient.GetTableReference(StorageInfo.ConfigurationTableName);
await this.configurationCloudTable.CreateIfNotExistsAsync();
}
19
Source : TokenHelper.cs
with MIT License
from OfficeDev
with MIT License
from OfficeDev
private async Task InitializeAsync()
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(this.connectionString);
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
CloudTable table = tableClient.GetTableReference(StorageInfo.TokenTableName);
await table.CreateIfNotExistsAsync();
this.cloudTable = table;
}
19
Source : BaseStorageProvider.cs
with MIT License
from OfficeDev
with MIT License
from OfficeDev
private async Task InitializeAsync()
{
// Exponential retry policy with backoff of 3 seconds and 5 retries.
var exponentialRetryPolicy = new TableRequestOptions()
{
RetryPolicy = new ExponentialRetry(TimeSpan.FromSeconds(3), 5),
};
try
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(this.connectionString);
CloudTableClient cloudTableClient = storageAccount.CreateCloudTableClient();
cloudTableClient.DefaultRequestOptions = exponentialRetryPolicy;
this.ResponsesCloudTable = cloudTableClient.GetTableReference(this.TableName);
await this.ResponsesCloudTable.CreateIfNotExistsAsync();
}
catch (Exception)
{
throw;
}
}
19
Source : ScrumProvider.cs
with MIT License
from OfficeDev
with MIT License
from OfficeDev
private async Task InitializeAsync(string connectionString)
{
try
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
CloudTableClient cloudTableClient = storageAccount.CreateCloudTableClient();
this.scrumCloudTable = cloudTableClient.GetTableReference("Scrum");
await this.scrumCloudTable.CreateIfNotExistsAsync();
}
catch (Exception ex)
{
this.telemetryClient.TrackException(ex);
this.telemetryClient.TrackTrace($"Exception : {ex.Message}");
}
}
19
Source : StickerStore.cs
with MIT License
from OfficeDev
with MIT License
from OfficeDev
private async Task InitializeAsync()
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(this.connectionString);
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
CloudTable table = tableClient.GetTableReference(this.tableName);
await table.CreateIfNotExistsAsync();
this.cloudTable = table;
}
19
Source : BaseStorageProvider.cs
with MIT License
from OfficeDev
with MIT License
from OfficeDev
private async Task<CloudTable> InitializeAsync()
{
// Exponential retry policy with back off of 3 seconds and 2 retries.
var exponentialRetryPolicy = new TableRequestOptions()
{
RetryPolicy = new ExponentialRetry(TimeSpan.FromSeconds(3), 2),
};
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(this.connectionString);
CloudTableClient cloudTableClient = storageAccount.CreateCloudTableClient();
cloudTableClient.DefaultRequestOptions = exponentialRetryPolicy;
this.CloudTable = cloudTableClient.GetTableReference(this.TableName);
await this.CloudTable.CreateIfNotExistsAsync();
return this.CloudTable;
}
19
Source : AzureTableStorageHelper.cs
with MIT License
from OfficeDev
with MIT License
from OfficeDev
public async Task<List<T>> FetchTableRecordsAsync<T>(string tableName, string parreplacedionKey)
where T : ITableEnreplacedy, new()
{
CloudTable table = this.TableClient.GetTableReference(tableName);
if (await table.CreateIfNotExistsAsync().ConfigureAwait(false))
{
return null;
}
else
{
TableQuery<T> query = new TableQuery<T>();
if (tableName != "UserToUserMapping")
{
query.Where(TableQuery.GenerateFilterCondition("ParreplacedionKey", QueryComparisons.Equal, parreplacedionKey));
}
// Results list
List<T> results = new List<T>();
TableContinuationToken continuationToken = null;
do
{
var queryResults = await table.ExecuteQuerySegmentedAsync(query, continuationToken).ConfigureAwait(false);
continuationToken = queryResults.ContinuationToken;
results.AddRange(queryResults.Results);
}
while (continuationToken != null);
return results;
}
}
19
Source : OpenShiftMappingEntityProvider.cs
with MIT License
from OfficeDev
with MIT License
from OfficeDev
private async Task InitializeAsync(string connectionString)
{
this.telemetryClient.TrackTrace($"{MethodBase.GetCurrentMethod().Name}");
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
CloudTableClient cloudTableClient = storageAccount.CreateCloudTableClient();
this.openShiftEnreplacedyMappingCloudTable = cloudTableClient.GetTableReference(OpenShiftMappingTableName);
await this.openShiftEnreplacedyMappingCloudTable.CreateIfNotExistsAsync().ConfigureAwait(false);
}
19
Source : TeamDepartmentMappingProvider.cs
with MIT License
from OfficeDev
with MIT License
from OfficeDev
private async Task InitializeAsync(string connectionString)
{
this.telemetryClient.TrackTrace($"{MethodBase.GetCurrentMethod().Name}");
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
CloudTableClient cloudTableClient = storageAccount.CreateCloudTableClient();
this.teamDepartmentMappingCloudTable = cloudTableClient.GetTableReference(TeamDepartmentMappingTableName);
await this.teamDepartmentMappingCloudTable.CreateIfNotExistsAsync().ConfigureAwait(false);
}
19
Source : StorageBaseProvider.cs
with MIT License
from OfficeDev
with MIT License
from OfficeDev
private async Task<CloudTable> InitializeAsync()
{
// Exponential retry policy with back off set to 3 seconds and 5 retries.
var exponentialRetryPolicy = new TableRequestOptions()
{
RetryPolicy = new ExponentialRetry(TimeSpan.FromSeconds(3), 5),
};
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(this.connectionString);
this.cloudTableClient = storageAccount.CreateCloudTableClient();
this.cloudTableClient.DefaultRequestOptions = exponentialRetryPolicy;
this.CloudTable = this.cloudTableClient.GetTableReference(this.tableName);
await this.CloudTable.CreateIfNotExistsAsync();
return this.CloudTable;
}
19
Source : AzureStorageScheduleConnectorService.cs
with MIT License
from OfficeDev
with MIT License
from OfficeDev
private CloudTable GetTableReference()
{
var account = CloudStorageAccount.Parse(_options.ConnectionString);
var client = account.CreateCloudTableClient();
return client.GetTableReference(_options.TeamTableName);
}
19
Source : AzureStorageTimeZoneService.cs
with MIT License
from OfficeDev
with MIT License
from OfficeDev
private CloudTable GetTableReference()
{
var account = CloudStorageAccount.Parse(_options.ConnectionString);
var client = account.CreateCloudTableClient();
return client.GetTableReference(_options.TimeZoneTableName);
}
19
Source : ConfigurationProvider.cs
with MIT License
from OfficeDev
with MIT License
from OfficeDev
private async Task InitializeAsync(string connectionString)
{
this.telemetryClient.TrackTrace($"{MethodBase.GetCurrentMethod().Name}");
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
CloudTableClient cloudTableClient = storageAccount.CreateCloudTableClient();
this.configurationCloudTable = cloudTableClient.GetTableReference(ConfigurationTableName);
await this.configurationCloudTable.CreateIfNotExistsAsync().ConfigureAwait(false);
}
19
Source : OpenShiftRequestMappingEntityProvider.cs
with MIT License
from OfficeDev
with MIT License
from OfficeDev
private async Task InitializeAsync(string connectionString)
{
this.telemetryClient.TrackTrace($"{MethodBase.GetCurrentMethod().Name}");
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
CloudTableClient cloudTableClient = storageAccount.CreateCloudTableClient();
this.openShiftRequestMappingCloudTable = cloudTableClient.GetTableReference(OpenShiftRequestMappingTableName);
await this.openShiftRequestMappingCloudTable.CreateIfNotExistsAsync().ConfigureAwait(false);
}
19
Source : TimeOffMappingEntityProvider.cs
with MIT License
from OfficeDev
with MIT License
from OfficeDev
private async Task InitializeAsync(string connectionString)
{
this.telemetryClient.TrackTrace($"{MethodBase.GetCurrentMethod().Name}");
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
CloudTableClient cloudTableClient = storageAccount.CreateCloudTableClient();
this.timeoffEnreplacedyMappingTable = cloudTableClient.GetTableReference(TimeOffTable);
await this.timeoffEnreplacedyMappingTable.CreateIfNotExistsAsync().ConfigureAwait(false);
}
19
Source : TimeOffReasonProvider.cs
with MIT License
from OfficeDev
with MIT License
from OfficeDev
private async Task InitializeAsync(string connectionString)
{
this.telemetryClient.TrackTrace("Ensuring azure table for time off reasons exists.");
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
CloudTableClient cloudTableClient = storageAccount.CreateCloudTableClient();
this.timeOffReasonsCloudTable = cloudTableClient.GetTableReference(ConfigurationTableName);
await this.timeOffReasonsCloudTable.CreateIfNotExistsAsync().ConfigureAwait(false);
}
See More Examples