private async Task ContactTableStorage() { CloudStorageAccount account = CloudStorageAccount.Parse(_storageConfig.TableConnectionString); CloudTableClient tableClient = account.CreateCloudTableClient(); CloudTable table = tableClient.GetTableReference(_storageConfig.MetadataTableName); await table.CreateIfNotExistsAsync(); }
public Task OpenAsync(PartitionContext context) { /*client = new HttpClient(); client.DefaultRequestHeaders.Add("X-ZUMO-APPLICATION", APP_KEY_MOBILE_SERVICES); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); return Task.FromResult<object>(null);*/ var storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString")); var tableClient = storageAccount.CreateCloudTableClient(); sensorLogTable = tableClient.GetTableReference("SensorLog"); //sensorLogTable = tableClient.GetTableReference("SensorLog" + context.Lease.PartitionId); // 閾値の取得 if (thresholdTempWarning == null) { var sensorConfigTable = tableClient.GetTableReference("SensorConfig"); var query = new TableQuery<SensorConfig>(); var configData = sensorConfigTable.ExecuteQuery(query); foreach (SensorConfig config in configData) { if (config.PartitionKey == "TemperatureWarning") { thresholdTempWarning = config.Threshold; System.Console.WriteLine("ThresholdTempWarning: " + thresholdTempWarning); } else if (config.PartitionKey == "TemperatureDanger") { thresholdTempDanger = config.Threshold; System.Console.WriteLine("ThresholdTempDanger: " + thresholdTempDanger); } } } return sensorLogTable.CreateIfNotExistsAsync(); }
private async Task EnsureTableExists(CloudTable table) { if (!this.created) { await table.CreateIfNotExistsAsync(); this.created = true; } }
public void MyTestInitialize() { CloudTableClient tableClient = GenerateCloudTableClient(); currentTable = tableClient.GetTableReference(GenerateRandomTableName()); currentTable.CreateIfNotExistsAsync().AsTask().Wait(); if (TestBase.TableBufferManager != null) { TestBase.TableBufferManager.OutstandingBufferCount = 0; } }
static async Task <Microsoft.WindowsAzure.Storage.Table.CloudTable> GetTable(string tableName) { CloudStorageAccount storageAccount = CloudStorageAccount.Parse( Constants.StorageConnection); Microsoft.WindowsAzure.Storage.Table.CloudTableClient tableClient = storageAccount.CreateCloudTableClient(); Microsoft.WindowsAzure.Storage.Table.CloudTable table = tableClient.GetTableReference(tableName); await table.CreateIfNotExistsAsync(); return(table); }
public AzureStorageRepository(string account, string key, string tableName, bool nagling = true) { _storageAccount = GetStorageAccount(account, key); _tableClient = _storageAccount.CreateCloudTableClient(); _table = _tableClient.GetTableReference(tableName); _table.CreateIfNotExistsAsync(); EnableNagling(nagling); }
public async Task SaveBench(WalkToSave entityToSave) { CloudStorageAccount account = CloudStorageAccount.Parse(_storageConfig.TableConnectionString); CloudTableClient tableClient = account.CreateCloudTableClient(); CloudTable table = tableClient.GetTableReference(_storageConfig.MetadataTableName); await table.CreateIfNotExistsAsync(); var result = await InsertEntity(table, entityToSave); if (result.HttpStatusCode != (int)HttpStatusCode.NoContent) { throw new ApplicationException("Failed to insert entity in database."); } }
public void Configure() { // Create the table client. _tableClient = _storageAccount.CreateCloudTableClient(); _urltable = _tableClient.GetTableReference("url"); _indextable = _tableClient.GetTableReference("index"); // Create the table if it doesn't exist _urltable.CreateIfNotExistsAsync().Wait(); _indextable.CreateIfNotExistsAsync().Wait(); // Create index if it doesn't exist createIndexIfNotExist().Wait(); }
public static async Task MyClassInitialize(TestContext testContext) { tableClient = GenerateCloudTableClient(); currentTable = tableClient.GetTableReference(GenerateRandomTableName()); await currentTable.CreateIfNotExistsAsync(); for (int i = 0; i < 15; i++) { TableBatchOperation batch = new TableBatchOperation(); for (int j = 0; j < 100; j++) { DynamicTableEntity ent = GenerateRandomEntity("tables_batch_" + i.ToString()); ent.RowKey = string.Format("{0:0000}", j); batch.Insert(ent); } await currentTable.ExecuteBatchAsync(batch); } }
public Program() { var builder = new ConfigurationBuilder("D:\\testproj\\src\\testproj"); builder.AddUserSecrets(); Configuration = builder.Build(); _version = Configuration["Authentication:AzureStorageAccount:version"]; // Retrieve the storage account from the connection string. _storageAccount = CloudStorageAccount.Parse(Configuration["Authentication:AzureStorageAccount:StorageConnectionString"]); // Create the table client. _tableClient = _storageAccount.CreateCloudTableClient(); // Create the table if it doesn't exist. _urltable = _tableClient.GetTableReference("url"); _urltable.CreateIfNotExistsAsync(); // Create the table if it doesn't exist. _indextable = _tableClient.GetTableReference("index"); _indextable.CreateIfNotExistsAsync(); }
public async Task <List <WalkToSave> > GetAllEntities() { CloudStorageAccount account = CloudStorageAccount.Parse(_storageConfig.TableConnectionString); CloudTableClient tableClient = account.CreateCloudTableClient(); CloudTable table = tableClient.GetTableReference(_storageConfig.MetadataTableName); await table.CreateIfNotExistsAsync(); var query = new TableQuery <WalkToSave>(); var entities = new List <WalkToSave>(); TableContinuationToken token = null; TableQuerySegment <WalkToSave> resultSegment = null; do { resultSegment = await table.ExecuteQuerySegmentedAsync <WalkToSave>(query, token); entities.AddRange(resultSegment.Results.OfType <WalkToSave>()); token = resultSegment.ContinuationToken; }while (token != null); return(entities); }
public async Task MyTestInitialize() { tableClient = GenerateCloudTableClient(); currentTable = tableClient.GetTableReference(GenerateRandomTableName()); await currentTable.CreateIfNotExistsAsync(); }
public void MyTestInitialize() { CloudTableClient tableClient = GenerateCloudTableClient(); currentTable = tableClient.GetTableReference(GenerateRandomTableName()); currentTable.CreateIfNotExistsAsync().AsTask().Wait(); }
public static async Task MyClassInitialize(TestContext testContext) { CloudTableClient tableClient = GenerateCloudTableClient(); currentTable = tableClient.GetTableReference(GenerateRandomTableName()); await currentTable.CreateIfNotExistsAsync(); // Bulk Query Entities for (int i = 0; i < 15; i++) { TableBatchOperation batch = new TableBatchOperation(); for (int j = 0; j < 100; j++) { var ent = GenerateRandomEntity("tables_batch_" + i.ToString()); ent.RowKey = string.Format("{0:0000}", j); batch.Insert(ent); } await currentTable.ExecuteBatchAsync(batch); } complexEntityTable = tableClient.GetTableReference(GenerateRandomTableName()); await complexEntityTable.CreateAsync(); // Setup TableBatchOperation complexBatch = new TableBatchOperation(); string pk = Guid.NewGuid().ToString(); for (int m = 0; m < 100; m++) { ComplexEntity complexEntity = new ComplexEntity(pk, string.Format("{0:0000}", m)); complexEntity.String = string.Format("{0:0000}", m); complexEntity.Binary = new byte[] { 0x01, 0x02, (byte)m }; complexEntity.BinaryPrimitive = new byte[] { 0x01, 0x02, (byte)m }; complexEntity.Bool = m % 2 == 0 ? true : false; complexEntity.BoolPrimitive = m % 2 == 0 ? true : false; complexEntity.Double = m + ((double)m / 100); complexEntity.DoublePrimitive = m + ((double)m / 100); complexEntity.Int32 = m; complexEntity.Int32N = m; complexEntity.IntegerPrimitive = m; complexEntity.IntegerPrimitiveN = m; complexEntity.Int64 = (long)int.MaxValue + m; complexEntity.LongPrimitive = (long)int.MaxValue + m; complexEntity.LongPrimitiveN = (long)int.MaxValue + m; complexEntity.Guid = Guid.NewGuid(); complexBatch.Insert(complexEntity); if (m == 50) { middleRef = complexEntity; } // Add delay to make times unique Thread.Sleep(100); } await complexEntityTable.ExecuteBatchAsync(complexBatch); }
public static async Task MyClassInitialize(TestContext testContext) { CloudTableClient tableClient = GenerateCloudTableClient(); currentTable = tableClient.GetTableReference(GenerateRandomTableName()); await currentTable.CreateIfNotExistsAsync(); // Bulk Query Entities for (int i = 0; i < 15; i++) { TableBatchOperation batch = new TableBatchOperation(); for (int j = 0; j < 100; j++) { var ent = GenerateRandomEnitity("tables_batch_" + i.ToString()); ent.RowKey = string.Format("{0:0000}", j); batch.Insert(ent); } await currentTable.ExecuteBatchAsync(batch); } complexEntityTable = tableClient.GetTableReference(GenerateRandomTableName()); await complexEntityTable.CreateAsync(); // Setup TableBatchOperation complexBatch = new TableBatchOperation(); string pk = Guid.NewGuid().ToString(); for (int m = 0; m < 100; m++) { ComplexEntity complexEntity = new ComplexEntity(pk, string.Format("{0:0000}", m)); complexEntity.String = string.Format("{0:0000}", m); complexEntity.Binary = new byte[] { 0x01, 0x02, (byte)m }; complexEntity.BinaryPrimitive = new byte[] { 0x01, 0x02, (byte)m }; complexEntity.Bool = m % 2 == 0 ? true : false; complexEntity.BoolPrimitive = m % 2 == 0 ? true : false; complexEntity.Double = m + ((double)m / 100); complexEntity.DoublePrimitive = m + ((double)m / 100); complexEntity.Int32 = m; complexEntity.Int32N = m; complexEntity.IntegerPrimitive = m; complexEntity.IntegerPrimitiveN = m; complexEntity.Int64 = (long)int.MaxValue + m; complexEntity.LongPrimitive = (long)int.MaxValue + m; complexEntity.LongPrimitiveN = (long)int.MaxValue + m; complexEntity.Guid = Guid.NewGuid(); complexBatch.Insert(complexEntity); if (m == 50) { middleRef = complexEntity; } // Add delay to make times unique Thread.Sleep(100); } await complexEntityTable.ExecuteBatchAsync(complexBatch); }