本文整理汇总了C#中Microsoft.WindowsAzure.Storage.Table.CloudTable.CreateIfNotExistsAsync方法的典型用法代码示例。如果您正苦于以下问题:C# CloudTable.CreateIfNotExistsAsync方法的具体用法?C# CloudTable.CreateIfNotExistsAsync怎么用?C# CloudTable.CreateIfNotExistsAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.WindowsAzure.Storage.Table.CloudTable
的用法示例。
在下文中一共展示了CloudTable.CreateIfNotExistsAsync方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OpenAsync
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();
}
示例2: EnsureTableExists
private async Task EnsureTableExists(CloudTable table)
{
if (!this.created)
{
await table.CreateIfNotExistsAsync();
this.created = true;
}
}
示例3: MyTestInitialize
public void MyTestInitialize()
{
CloudTableClient tableClient = GenerateCloudTableClient();
currentTable = tableClient.GetTableReference(GenerateRandomTableName());
currentTable.CreateIfNotExistsAsync().AsTask().Wait();
if (TestBase.TableBufferManager != null)
{
TestBase.TableBufferManager.OutstandingBufferCount = 0;
}
}
示例4: AzureStorageRepository
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);
}
示例5: Configure
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();
}
示例6: MyClassInitialize
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);
}
}
示例7: Program
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();
}
示例8: MyTestInitialize
public async Task MyTestInitialize()
{
tableClient = GenerateCloudTableClient();
currentTable = tableClient.GetTableReference(GenerateRandomTableName());
await currentTable.CreateIfNotExistsAsync();
}
示例9: MyTestInitialize
public void MyTestInitialize()
{
CloudTableClient tableClient = GenerateCloudTableClient();
currentTable = tableClient.GetTableReference(GenerateRandomTableName());
currentTable.CreateIfNotExistsAsync().AsTask().Wait();
}
示例10: MyClassInitialize
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);
}