6-Minute Tutorial - Windows Azure Development - Unit Tests to Interact with Storage–Tables, Blobs, Queues

image

  Continuation of Previous Post
 

This post is a continuation of the previous post.

hyperlink2  

Previous Blog Post

Understanding on how to work with tables, blobs, and queues is the hallmark of cloud computing. Although many developers may choose a relational data store, they won’t be able to achieve the same scalability and throughput of Azure tables, blobs, and queues.

This post is all about using tables, blobs, and queues in a simple manner.

------------------------------------------------------- FabricIsOn() If pass, the fabric is already up and running ------------------------------------------------------- StartDevFabric() If pass, you started and verified fabric is up and running ------------------------------------------------------- StopDevFabric() If pass, you could stop the fabric ------------------------------------------------------- ValidateBlobStorageInit() If pass, you could create or get access to a blob and container and set permissions for it ------------------------------------------------------- ValidateQueue() If pass, you could create an Azure queue object ------------------------------------------------------- ValidateUploadBlob() If pass, I was able to upload an arbirary file. Mine was C:\azureSamples\WhackyPhotos\TestProject\images\image.jpg ------------------------------------------------------- void UploadBlob() Helper function for ValidateUploadBlob() ------------------------------------------------------- ValidateTables() If pass, I was able to add an entity like this:                 GuestName = "Bruno Guest Name",                 Message = "Bruno Message",                 PhotoUrl = "image.jpg",                 ThumbnailUrl = "the URI goes here" + timeStamp

------------------------------------------------------- DeleteTable() If pass, I could delete a table one entity at a time. ------------------------------------------------------- ValidateQueue2() If pass, runs the following: -DeleteTable(); -ValidateUploadBlob(); -ValidateTables(); Also, must retrieve inserted table entity and post entry to queue ------------------------------------------------------- ProcessQueue() If pass, it must do a lot of cumulative work. It must:   - Connect to local development storage   - Initialize blob storage and get to the 'guestbookpics'   - Do some validations for the blob containers of our photos     - 127.0.0.1:10000/devstoreaccount1/guestbookpics",   - Get connected to our queues   - Loop until we get our storage initialized   - Create the blob container (if does not exist) and allow public access   - Create a queue to hold messages for our worker role to consume   - Get a reference to our queue to read/write from/to   - Create the message queue if does not exist   - Quit out of the loop, mission accomplished   - Get a reference to our queue to read/write from/to   - Get ready to select data from Azure tables   - Create an Simply object that reprents our data for the   -    Azure tables ( GuestName, Message, PhotoUrl, ThumbnailUrl)   - Connect to table endpoint   - Select all the records from Azure Table   - Grab the first one.   - If no records, then create a record to test with   - We'll supply a temporary time stamp for our "ThumbnailUrl"   - Create an entity so we can do an insert   - Set the try policy and do the actual insert     - 127.0.0.1:10002/devstoreaccount1",   - Now that we have data, let's select it back out   - if failed, then table is empty, must have been an error   - Grab the unique "PhotoUrl" of our inserted image   - Clear out the queue   - Compose a message that we will add to the queue   - Add the message to the queue     - 127.0.0.1:10001/devstoreaccount1/guestthumbs");   - Loop, making thumbnails while the queue has messages to read   - Retrieve a new message from the queue   - If message is there, process it. If no message, sleep and try again soon.   - Parse message retrieved from queue. It is just a comma-separated string   - Download original image from blob storage. We can make a thumbnail if we   - don't have the full fidelity photo   - Data type to stream an image to   - client   - Data structure to hold image in memory   - Download to client   - Create a thumbnail image and upload into a blob. Just add "_thumb" to the filename   - Grab the uri from the cloud.   - Update the entry in table storage to point to the thumbnail. Notice that we ultimately   - save an object with Azure tables ( GuestName, Message, PhotoUrl, ThumbnailUrl)   - Prepare a data for use, async if desired. Other functions include Delete, Check if exist, List tables   - Select from the table using the partition and row keys   - Will return one row only. But "Default" helps because will give you a null object   - The whole point is to update the "ThumbnailUrl" column with the path of the new   - thumbnail file   - You need both an "Update" and a "Save"   - Remove message from queue. Since thumbnail is done, remove queue message.

  Video
  A 6 minute video is posted. This video is super high quality. It is crystal clear. Download it and play it at your convenience. Typically, it is just a 4 minute download.
  Code
  Snippet – Using Statements
hyperlink2  

Download using code

Snippet – Remaining Unit Tests and Helper Functions
hyperlink2  

Download remaining unit tests and helper functions

Snippet – WhackyPhotosDataContext
hyperlink2  

Download WhackyPhotosDataContext Class

Snippet – WhackyPhotosEntity
hyperlink2  

Download WhackyPhotosEntity Class