public static void SetSerivceProperties(Constants.ServiceType serviceType, Microsoft.WindowsAzure.Storage.Shared.Protocol.ServiceProperties serviceProperties) { switch (serviceType) { case Constants.ServiceType.Blob: StorageAccount.CreateCloudBlobClient().SetServiceProperties(serviceProperties); break; case Constants.ServiceType.Queue: StorageAccount.CreateCloudQueueClient().SetServiceProperties(serviceProperties); break; case Constants.ServiceType.Table: StorageAccount.CreateCloudTableClient().SetServiceProperties(serviceProperties); break; case Constants.ServiceType.File: FileServiceProperties fileProperties = new FileServiceProperties(); fileProperties.Cors = serviceProperties.Cors; fileProperties.HourMetrics = serviceProperties.HourMetrics; fileProperties.MinuteMetrics = serviceProperties.MinuteMetrics; StorageAccount.CreateCloudFileClient().SetServiceProperties(fileProperties); break; } }
public async Task Table_IfBoundToICollectorJObject_AddInsertsEntity() { // Arrange const string expectedValue = "abc"; StorageAccount account = CreateFakeStorageAccount(); CloudQueue triggerQueue = await account.CreateQueueAsync(TriggerQueueName); await triggerQueue.AddMessageAsync(new CloudQueueMessage(expectedValue)); // Act RunTrigger(account, typeof(BindToICollectorJObjectProgram)); // Assert CloudTableClient client = account.CreateCloudTableClient(); CloudTable table = client.GetTableReference(TableName); Assert.True(await table.ExistsAsync()); DynamicTableEntity entity = table.Retrieve <DynamicTableEntity>(PartitionKey, RowKey); Assert.NotNull(entity); Assert.NotNull(entity.Properties); AssertPropertyValue(entity, "ValueStr", "abcdef"); AssertPropertyValue(entity, "ValueNum", 123); }
public AzureTableStorage(string tableStorageConnectionString, string tableName) { TableStorageConnectionString = tableStorageConnectionString; StorageAccount = CloudStorageAccount.Parse(TableStorageConnectionString); TableClient = StorageAccount.CreateCloudTableClient(); AzureSearchTable = TableClient.GetTableReference(tableName); }
/// <summary> /// This method initiialises the table storage connector. /// </summary> public override void Initialize() { Client = StorageAccount.CreateCloudTableClient(); if (RequestOptionsDefault != null) { Client.DefaultRequestOptions = RequestOptionsDefault ?? new TableRequestOptions() { RetryPolicy = new LinearRetry(TimeSpan.FromMilliseconds(200), 5) , ServerTimeout = DefaultTimeout ?? TimeSpan.FromSeconds(1) //, ParallelOperationThreadCount = 64 } } ; if (ContainerId == null) { ContainerId = AzureStorageHelper.GetEnum <DataCollectionSupport>(Support).StringValue; } ContainerId = StorageServiceBase.ValidateAzureContainerName(ContainerId); // Retrieve a reference to the table. Table = Client.GetTableReference(ContainerId); // Create the table if it doesn't exist. Table.CreateIfNotExists(); }
public SessionRepository(String storageConnectionString) { StorageAccount = CloudStorageAccount.Parse(storageConnectionString); TableClient = StorageAccount.CreateCloudTableClient(); SessionTable = TableClient.GetTableReference("Sessions"); SessionTable.CreateIfNotExists(); }
public TableStorageRepo() { StorageAccount = CloudStorageAccount .Parse("DefaultEndpointsProtocol=https;AccountName=anishstoragedemo;AccountKey=KRohowEAfydP3O7KtPlXqlyoUPyPlJI5cp9dQ5cPpmkncnQpPNVDGszUH6p7FptXqn23D6/sRI1mKdtFwgX1qw==;EndpointSuffix=core.windows.net"); CloudTableClient = StorageAccount?.CreateCloudTableClient(); TableRef = this.CloudTableClient.GetTableReference("Todo"); }
public DumplingStorageAccount(string connection_string) { StorageAccount = CloudStorageAccount.Parse(connection_string); BlobClient = StorageAccount.CreateCloudBlobClient(); TableClient = StorageAccount.CreateCloudTableClient(); FileClient = StorageAccount.CreateCloudFileClient(); }
public AzureTableRowStorage(IConfiguration configuration) { string connectionString = configuration.GetValue <string>("AzureWebJobsStorage"); StorageAccount storageAccount = StorageAccount.NewFromConnectionString(connectionString); _tableClient = storageAccount.CreateCloudTableClient(); }
public void EnumerateAllTables() { //--------------Get operation-------------- Test.Assert(CommandAgent.GetAzureStorageTable(""), Utility.GenComparisonData("EnumerateAllTables", true)); // Verification for returned values CommandAgent.OutputValidation(StorageAccount.CreateCloudTableClient().ListTables()); }
public CommRepository(StorageAccount storageAccount) { _blobClient = storageAccount.CreateCloudBlobClient(); _cloudTableClient = storageAccount.CreateCloudTableClient(); _cloudQueueClient = storageAccount.CreateCloudQueueClient(); }
public static void ClassInit(TestContext context) { CloudStorageEmulatorShepherd shepherd = new CloudStorageEmulatorShepherd(); shepherd.Start(); StorageAccount = CloudStorageAccount.DevelopmentStorageAccount; TableClient = StorageAccount.CreateCloudTableClient(); }
/// <summary> /// Get a reference to the table. If one doesn't exist create it. /// </summary> /// <param name="tableAddress">Table address (name).</param> /// <returns>Reference to the table.</returns> private CloudTable GetTableReference( string tableAddress) { var tableClient = StorageAccount.CreateCloudTableClient(); var table = tableClient.GetTableReference(tableAddress); table.CreateIfNotExists(); return(table); }
private void GetCloudTableClient() { if (String.IsNullOrEmpty(ConnectionString)) { LoadConnectionString(); } _tableClient = StorageAccount.CreateCloudTableClient(); }
public StorageRepository(StorageAccount storageAccount, CosmosClient cosmosClient) { _blobClient = storageAccount.CreateCloudBlobClient(); _cloudTableClient = storageAccount.CreateCloudTableClient(); _cloudQueueClient = storageAccount.CreateCloudQueueClient(); _cosmosClient = cosmosClient; var result = CreateStorageIfNotExists().Result; }
async Task <IEnumerable <string> > IEntityRepository.GetEntities() { var tableClient = StorageAccount.CreateCloudTableClient(); var table = tableClient.GetTableReference(TableName); var query = new TableQuery <LuisEntityTableEntity>(); TableContinuationToken token = null; // if there's more than 1000 rows in the table, this will need to be checked var queryResult = await table.ExecuteQuerySegmentedAsync(query, token); var result = queryResult.ToList(); return(result.Select(s => s.Name)); }
public static void ClassInit(TestContext context) { CloudStorageEmulatorShepherd shepherd = new CloudStorageEmulatorShepherd(); shepherd.Start(); StorageAccount = CloudStorageAccount.Parse(DevelopmentStorageAccountConnectionString); TableClient = StorageAccount.CreateCloudTableClient(); CloudTable testTable = SessionRepository.GetTableForSessionData(TableClient, SessionId); testTable.DeleteIfExists(); }
public static void ClassInit(TestContext context) { CloudStorageEmulatorShepherd shepherd = new CloudStorageEmulatorShepherd(); shepherd.Start(); StorageAccount = CloudStorageAccount.DevelopmentStorageAccount; TableClient = StorageAccount.CreateCloudTableClient(); CommandTable = CommandQueue.GetCommandQueueTableForSession(TableClient, SessionGuid); CommandTable.DeleteIfExists(); CommandTable.CreateIfNotExists(); }
public void OneTimeSetUp() { Setup.Bootstrap(SetupType.Test); CatRepository = IocWrapper.Instance.GetService <ICatRepository>(); var settings = IocWrapper.Instance.GetService <ISettings>(); StorageAccount = CloudStorageAccount.Parse(settings.TableStorageConnectionString); var tableClient = StorageAccount.CreateCloudTableClient(new TableClientConfiguration()); CatsTable = tableClient.GetTableReference(settings.CatEntityTableName); }
public static void ClassInit(TestContext context) { CloudStorageEmulatorShepherd shepherd = new CloudStorageEmulatorShepherd(); shepherd.Start(); StorageAccount = CloudStorageAccount.Parse(DevelopmentStorageAccountConnectionString); TableClient = StorageAccount.CreateCloudTableClient(); SessionTable = TableClient.GetTableReference("Sessions"); SessionPlayerTable = TableClient.GetTableReference("SessionPlayers"); SessionTable.DeleteIfExists(); SessionPlayerTable.DeleteIfExists(); }
public void RemoveNonExistingTable() { string TABLE_NAME = Utility.GenNameString("nonexisting"); // Delete the table if it exists CloudTable table = StorageAccount.CreateCloudTableClient().GetTableReference(TABLE_NAME); table.DeleteIfExists(); //--------------Remove operation-------------- Test.Assert(!CommandAgent.RemoveAzureStorageTable(TABLE_NAME), Utility.GenComparisonData("RemoveAzureStorageTable", false)); // Verification for returned values Test.Assert(CommandAgent.Output.Count == 0, "Only 0 row returned : {0}", CommandAgent.Output.Count); CommandAgent.ValidateErrorMessage(MethodBase.GetCurrentMethod().Name, TABLE_NAME); }
public static void Initialize() { StorageAccount = CloudStorageAccount.Parse(connectionString); // Disabling nagle for table improves performance: // https://blogs.msdn.microsoft.com/windowsazurestorage/2010/06/25/nagles-algorithm-is-not-friendly-towards-small-requests/ var tableServicePoint = ServicePointManager.FindServicePoint(StorageAccount.TableEndpoint); tableServicePoint.UseNagleAlgorithm = false; TableClient = StorageAccount.CreateCloudTableClient(); BlobClient = StorageAccount.CreateCloudBlobClient(); BlobContainer = BlobClient.GetContainerReference($"saga-{Configuration.TierAffix}-container"); BlobContainer.CreateIfNotExists(); }
private async Task Initialzie() { if (StorageAccount == null) { // Retrieve storage account from connection string. StorageAccount = CloudStorageAccount.Parse(_connectionString); // Create the table client TableClient = StorageAccount.CreateCloudTableClient(); // Retrieve reference to a previously created container. CloudTable = TableClient.GetTableReference(_imageTableName); // Create the container if it doesn't already exist. await CloudTable.CreateIfNotExistsAsync(); } }
public void SetLoggingVersion() { //Blob service CloudBlobClient blobClient = StorageAccount.CreateCloudBlobClient(); GenericSetLoggingVersion(ServiceType.Blob, () => blobClient.GetServiceProperties()); //Queue service CloudQueueClient queueClient = StorageAccount.CreateCloudQueueClient(); GenericSetLoggingVersion(ServiceType.Queue, () => queueClient.GetServiceProperties()); //Table service CloudTableClient tableClient = StorageAccount.CreateCloudTableClient(); GenericSetLoggingVersion(ServiceType.Table, () => tableClient.GetServiceProperties()); }
/// <summary> /// Initializes a new instance of the <see cref="ConfigResolverTableStorage"/> class. /// </summary> /// <param name="storageAccount">The storage account.</param> /// <param name="tableName">Name of the table.</param> /// <param name="partitionKey">The table partition key for the configuration settings.</param> /// <param name="propertyKey">The Azure table storage configuration default property key, currently "Value"</param> /// <param name="RequestOptionsDefault">You can set this to enable a more specific retry policy.</param> public ConfigResolverTableStorage(CloudStorageAccount storageAccount , string tableName = AzureExtensionMethods.AzureTableStorageConfigDefaultTableName , string partitionKey = AzureExtensionMethods.AzureTableStorageConfigDefaultPartitionKey , string propertyKey = AzureExtensionMethods.AzureTableStorageConfigDefaultPropertyKey , TableRequestOptions RequestOptionsDefault = null ) { PartitionKey = partitionKey ?? ""; PropertyKey = propertyKey ?? throw new ArgumentNullException("propertyKey", $"{nameof(ConfigResolverTableStorage)} propertyKey cannot be null"); TableName = tableName ?? throw new ArgumentNullException("tableName", $"{nameof(ConfigResolverTableStorage)} tableName cannot be null"); StorageAccount = storageAccount ?? throw new ArgumentNullException("storageAccount", $"{nameof(ConfigResolverTableStorage)} storageAccount cannot be null"); Client = StorageAccount.CreateCloudTableClient(); Client.DefaultRequestOptions = RequestOptionsDefault ?? DefaultTableRequestOptions(); Table = Client.GetTableReference(TableName); }
public void OneTimeSetUp() { Setup.Bootstrap(SetupType.Test); CatRepository = IocWrapper.Instance.GetService <ICatRepository>(); var settings = IocWrapper.Instance.GetService <ISettings>(); StorageAccount = CloudStorageAccount.Parse(settings.StorageAccountConnection); var tableClient = StorageAccount.CreateCloudTableClient(new TableClientConfiguration()); CatsTable = tableClient.GetTableReference(settings.CatEntityTableName); foreach (var cat in TestData.Cats) { CatsTable.Execute(TableOperation.Insert(cat)); } }
public static void InitializeConnections() { string connectionString = SharedConfig.AzureStorageConnectionString; AzureStorage.StorageAccount = CloudStorageAccount.Parse(connectionString); CloudTableClient tableClient = StorageAccount.CreateCloudTableClient(); AccountTable = tableClient.GetTableReference("account"); AccountTable.CreateIfNotExists(); ActivityTable = tableClient.GetTableReference("activity"); ActivityTable.CreateIfNotExists(); CloudQueueClient queueClient = StorageAccount.CreateCloudQueueClient(); SubscriptionQueue = queueClient.GetQueueReference("subscriptions"); SubscriptionQueue.CreateIfNotExists(); }
public async Task Table_IfBoundToCloudTable_BindsAndCreatesTable() { // Arrange StorageAccount account = CreateFakeStorageAccount(); CloudQueue triggerQueue = await account.CreateQueueAsync(TriggerQueueName); await triggerQueue.AddMessageAsync(new CloudQueueMessage("ignore")); // Act CloudTable result = RunTrigger <CloudTable>(account, typeof(BindToCloudTableProgram), (s) => BindToCloudTableProgram.TaskSource = s); // Assert Assert.NotNull(result); Assert.Equal(TableName, result.Name); CloudTableClient client = account.CreateCloudTableClient(); CloudTable table = client.GetTableReference(TableName); Assert.True(await table.ExistsAsync()); }
public void SetMetricsVersion() { //Blob service CloudBlobClient blobClient = StorageAccount.CreateCloudBlobClient(); GenericSetMetricsVersion(ServiceType.Blob, () => blobClient.GetServiceProperties()); //Queue service CloudQueueClient queueClient = StorageAccount.CreateCloudQueueClient(); GenericSetMetricsVersion(ServiceType.Queue, () => queueClient.GetServiceProperties()); //Table service CloudTableClient tableClient = StorageAccount.CreateCloudTableClient(); GenericSetMetricsVersion(ServiceType.Table, () => tableClient.GetServiceProperties()); //File service GenericSetMetricsVersion(ServiceType.File, () => Utility.GetServiceProperties(StorageAccount, ServiceType.File)); }
public override void Initialize() { Client = StorageAccount.CreateCloudTableClient(); if (RequestOptionsDefault != null) { Client.DefaultRequestOptions = RequestOptionsDefault; } if (ContainerId == null) { ContainerId = AzureStorageHelper.GetEnum <DataCollectionSupport>(Support).StringValue; } ContainerId = StorageServiceBase.ValidateAzureContainerName(ContainerId); // Retrieve a reference to the table. Table = Client.GetTableReference(ContainerId); // Create the table if it doesn't exist. Table.CreateIfNotExists(); }
private async static Task Clean(StorageAccount account) { CloudBlobClient blobClient = account.CreateCloudBlobClient(); foreach (var testContainer in (await blobClient.ListContainersSegmentedAsync(TestArtifactPrefix, null)).Results) { await testContainer.DeleteAsync(); } CloudTableClient tableClient = account.CreateCloudTableClient(); foreach (var table in await tableClient.ListTablesSegmentedAsync(TestArtifactPrefix, null)) { await table.DeleteAsync(); } CloudQueueClient queueClient = account.CreateCloudQueueClient(); foreach (var queue in (await queueClient.ListQueuesSegmentedAsync(TestArtifactPrefix, null)).Results) { await queue.DeleteAsync(); } }