CreateTableAsync() public static method

Create a table for the sample application to process messages in.
public static CreateTableAsync ( string tableName ) : Task
tableName string
return Task
        public async Task RunSamples()
        {
            Console.WriteLine("Azure Table Storage - Basic Samples\n");
            Console.WriteLine();
            string accountName = CloudConfigurationManager.GetSetting("CosmosAccount");
            string accountKey  = CloudConfigurationManager.GetSetting("CosmosKey");

            string tableName = "demo" + Guid.NewGuid().ToString().Substring(0, 5);

            // Create or reference an existing table
            CloudTable table = await Common.CreateTableAsync(tableName, accountName, accountKey);

            await UpdateCosmosTablesRUs(accountName, accountKey, tableName, 1000);

            try
            {
                // Demonstrate basic CRUD functionality
                await BasicDataOperationsAsync(table);
            }
            finally
            {
                // Delete the table
                //await table.DeleteIfExistsAsync();
                await UpdateCosmosTablesRUs(accountName, accountKey, tableName, 400);
            }
        }
        public async Task RunSamples()
        {
            Console.WriteLine("Azure Table Storage - 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 storage 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
            {
                Console.WriteLine("Delete the Table? [Y]es or [N]o ");
                var delete = Console.ReadKey();
                if (delete.ToString().ToUpper() == "Y")
                {
                    // Delete the table
                    await table.DeleteIfExistsAsync();
                }
            }
        }
Esempio n. 3
0
        public async Task RunSamples()
        {
            Console.WriteLine("Azure Table Storage - Basic 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);

            try
            {
                // Demonstrate basic CRUD functionality
                await BasicDataOperationsAsync(table);
            }
            finally
            {
                // Delete the table
                await table.DeleteIfExistsAsync();
            }
        }
Esempio n. 4
0
        public async Task RunSamples()
        {
            Console.WriteLine("Azure Table Storage - 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 storage account
                await TableListingOperations(tableClient);

                // Service Properties
                await ServicePropertiesSample(tableClient);

                // CORS
                await CorsSample(tableClient);

                // Service Stats
                await ServiceStatsSample(tableClient);

                // Table Acl
                await TableAclSample(table);
            }
            finally
            {
                // Delete the table
                await table.DeleteIfExistsAsync();
            }
        }
Esempio n. 5
0
        private async void LikesAsync(string number_of_loaded_likes)
        {
            string tableName = "FacebookLikesData" + Guid.NewGuid().ToString().Substring(0, 5);

            // Create or reference an existing table
            CloudTable table = await Common.CreateTableAsync(tableName);

            var client = new FacebookClient();

            client.AccessToken = this.access_token;



            //show user's profile picture
            dynamic me           = client.Get("me/posts?fields=likes,message,created_time,full_picture&limit=" + number_of_loaded_likes);
            var     facebookData = me.data;

            foreach (var element in facebookData)
            {
                if (element.message != null)
                {
                    FacebookLikesEntity post = new FacebookLikesEntity(element.id, element.created_time)
                    {
                        Message_or_photo = element.message,
                        Total_likes      = 0
                    };

                    post = await InsertOrMergeEntityAsync(table, post);

                    ListViewItem item = new ListViewItem(element.message);
                    item.SubItems.Add(element.created_time);

                    if (element.likes != null)
                    {
                        string x = Convert.ToString(element.likes.data.Count);
                        item.SubItems.Add(x);
                        TotalLikesForPosts(element.likes.data.Count, 0);
                        post.Total_likes = element.likes.data.Count;
                        await InsertOrMergeEntityAsync(table, post);
                    }
                    else
                    {
                        item.SubItems.Add("No likes for this post");
                    }
                    postsList.Items.Add(item);
                }
                else if (element.full_picture != null)
                {
                    FacebookLikesEntity post = new FacebookLikesEntity(element.id, element.created_time)
                    {
                        Message_or_photo = element.full_picture,
                        Total_likes      = 0
                    };

                    post = await InsertOrMergeEntityAsync(table, post);

                    ListViewItem item = new ListViewItem(element.full_picture);
                    item.SubItems.Add(element.created_time);
                    if (element.likes != null)
                    {
                        string x = Convert.ToString(element.likes.data.Count);
                        item.SubItems.Add(x);
                        post.Total_likes = element.likes.data.Count;
                        TotalLikesForPosts(element.likes.data.Count, 0);
                        await InsertOrMergeEntityAsync(table, post);
                    }
                    else
                    {
                        item.SubItems.Add("No likes for this photo");
                    }
                    postsList.Items.Add(item);
                }
            }
            this.deleteTables.Click += (sender, EventArgs) => { deleteTables_ClickAsync(sender, EventArgs, table); };
        }