private static void RunQueueCode(PictureEntity picture) { Console.WriteLine("\n\nStarting Queue Demo..."); // Parse the connection string and return a reference to the storage account. CloudStorageAccount storageAccount = CloudStorageAccount.Parse( CloudConfigurationManager.GetSetting("StorageConnectionString")); // Create the queue client. CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient(); // Get or create the queue CloudQueue queue = queueClient.GetQueueReference("notifications"); queue.CreateIfNotExists(); // Peek the queue CloudQueueMessage peekedMessage = queue.PeekMessage(); Console.WriteLine("Top of queue before new message: " + (peekedMessage == null ? "" : peekedMessage.AsString)); // Create a message and add it to the queue. CloudQueueMessage message = new CloudQueueMessage("Created picture metadata:\n" + " Partition Key :" + picture.PartitionKey + "\n" + " Row Key: " + picture.RowKey + "\n"); queue.AddMessage(message); Console.WriteLine("Added message to queue: " + message.AsString); }
private static PictureEntity RunTableCode(CloudBlockBlob blob) { Console.WriteLine("\n\nStarting Table Demo..."); // Parse the connection string and return a reference to the storage account. CloudStorageAccount storageAccount = CloudStorageAccount.Parse( CloudConfigurationManager.GetSetting("StorageConnectionString")); // Create the table client. CloudTableClient tableClient = storageAccount.CreateCloudTableClient(); // Get or create the table CloudTable table = tableClient.GetTableReference("pictures"); table.CreateIfNotExists(); PictureEntity picture = new PictureEntity(blob.Name); picture.FileSize = blob.Properties.Length; picture.BlobUri = blob.Uri.ToString(); TableOperation insert = TableOperation.Insert(picture); table.Execute(insert); Console.WriteLine("'Picture' TableEntity properties: "); foreach (var prop in picture.GetType().GetProperties()) { Console.WriteLine(" " + prop.Name + ": " + prop.GetValue(picture, null)); } Console.WriteLine("\nWrote metadata entity into " + table.Name + " table."); TableQuery <PictureEntity> query = new TableQuery <PictureEntity>() .Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, picture.PartitionKey)); Console.WriteLine("Entries for this picture: " + table.ExecuteQuery(query).Count()); return(picture); }