public async Task RunSamples() { Console.WriteLine("Azure Cosmos DB Table - Advanced Samples\n"); Console.WriteLine(); string tableName = "demo" + Guid.NewGuid().ToString().Substring(0, 5); // Create or reference an existing table CloudTable table = await Common.CreateTableAsync(tableName); CloudTableClient tableClient = table.ServiceClient; try { // Demonstrate advanced functionality such as batch operations and segmented multi-entity queries await AdvancedDataOperationsAsync(table); // List tables in the account await TableListingOperations(tableClient); if (!SamplesUtils.IsAzureCosmosdbTable()) { // Create a SAS and try CRUD operations with the SAS. await AdvancedDataOperationsWithSasAsync(table); // Service Properties await ServicePropertiesSample(tableClient); // CORS await CorsSample(tableClient); // Service Stats await ServiceStatsSample(tableClient); // Table Acl await TableAclSample(table); // Create a SAS and try CRUD operations with the SAS and shared access policy on the table. await AdvancedDataOperationsWithSasAndSharedAccessPolicyOnTableAsync(table); } } finally { // Delete the table await table.DeleteIfExistsAsync(); } }
private static async Task AdvancedDataOperationsAsync(CloudTable table) { // Demonstrate upsert and batch table operations Console.WriteLine("Inserting a batch of entities. "); await BatchInsertOfCustomerEntitiesAsync(table, "Smith"); Console.WriteLine(); // Query a range of data within a partition using a simple query Console.WriteLine("Retrieving entities with surname of Smith and first names >= 1 and <= 75"); ExecuteSimpleQuery(table, "Smith", "0001", "0075"); Console.WriteLine(); // Query the same range of data within a partition and return result segments of 50 entities at a time Console.WriteLine("Retrieving entities with surname of Smith and first names >= 1 and <= 75"); await PartitionRangeQueryAsync(table, "Smith", "0001", "0075"); Console.WriteLine(); // Query for all the data within a partition Console.WriteLine("Retrieve entities with surname of Smith."); await PartitionScanAsync(table, "Smith"); Console.WriteLine(); if (SamplesUtils.IsAzureCosmosdbTable()) { // Demonstrate upsert and batch table operations Console.WriteLine("Inserting a batch of entities. "); await BatchInsertOfCustomerEntitiesAsync(table, "Dave"); Console.WriteLine(); // Demonstrate upsert and batch table operations Console.WriteLine("Inserting a batch of entities. "); await BatchInsertOfCustomerEntitiesAsync(table, "Shirly"); Console.WriteLine(); //Query for all the data cross partition with order by Console.WriteLine("Query with order by cross partition"); await ExecuteCrossPartitionQueryWithOrderBy(table, "0001", "0025"); Console.WriteLine(); } }