Introducing Windows Azure- P28 pps

5 259 0
Introducing Windows Azure- P28 pps

Đang tải... (xem toàn văn)

Thông tin tài liệu

CHAPTER 3 ■ WORKING WITH CLOUD QUEUE AND BLOB STORAGE 108 string blobName = combBoxBlobList.SelectedItem.ToString(); try { BlobProperties properties = new BlobProperties(blobName); NameValueCollection metadata = new NameValueCollection(); properties.Metadata = metadata; properties.ContentType = "byte"; BlobContents blobContents = new BlobContents(new MemoryStream()); _command = new DeleteBlobStatus(blobContents, properties, true); _backgroundWorkeComponent._QueuedBackgroundWorker.RunWorkerAsync(_command); } catch (Exception ex) { toolStripStatusLabel1.ForeColor = Color.Red; toolStripStatusLabel1.Text = ex.Message; } } Listing 3-23. Set Flag from QueuedBackgroundWorker to Interrupt Create or Delete Blob Actions private void btnCancel Click(object sender, EventArgs e) { timer1.Enabled = false; btnUpload.Enabled = true; btnDelete.Enabled = true; btnAbort.Enabled = false; toolStripStatusLabel1.Text = "Actiong aborted."; _backgroundWorkeComponent._QueuedBackgroundWorker.CancelAllAsync(); } ■ Note To run this application from the local development environment, the development storage service and development fabric must be started first. The following screenshots are the test results of Exercise 3-4. CHAPTER 3 ■ WORKING WITH CLOUD QUEUE AND BLOB STORAGE 109 First, we upload a large amount of data to blob storage. The results are shown in Figures 3-13 and 3-14. Figure 3-13. File of size 278 MB created and uploaded to blob, taking 61.358 seconds in the local development environment with the system configuration shown in Figure 3-14 Figure 3-14. System configuration to run Exercise 3-4 We can also upload a small amount of data to blob storage. CHAPTER 3 ■ WORKING WITH CLOUD QUEUE AND BLOB STORAGE 110 This tool, of course, can also be used to transmit any size of data between local systems and cloud blob storage. Figure 3-15 shows an example using this tool to upload a small file to a blob storage table. Note that the file name created by the tool in this case has no suffix. Figure 3-15. Creating a small blob Since the job is done from a queued worker thread running in the background, aborting an action turns out to be very easy; you can simply click on the Abort button to interrupt the processing as Figure 3-16 shows. Figure 3-16. The background blob create action can easily be interrupted and aborted at any time. To delete a record from blob storage, select an available item from the list and click the Delete button. All information retrieved by this tool is in raw data format, as shown in Figure 3-17. One enhancement would be to display the information as a human readable string or provide mapping information for the user, both of which would help to prevent accidental record deletion. CHAPTER 3 ■ WORKING WITH CLOUD QUEUE AND BLOB STORAGE 111 Figure 3-17. All blobs in the specified container are queried and listed in the drop-down list. Summary In this chapter we looked at the final two forms of basic storage provided by Azure: Blob and Queue. When they are combined, we can create some powerful, loosely coupled systems to link our applications together. I showed you how to create a cloud queue and how to poll messages from it, as well as how to remove messages when you have processed them. I followed that up by showing how to create blob storage. The natural thing to do was combine the two into a loosely coupled, event-driven system that takes advantage of these two technologies. I provided a full example that handled events and notifications using a queue. The final example was a tool to help you work with blob storage.

Ngày đăng: 05/07/2014, 01:20

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan