Azure Services Discovery-Storage BLOBs Storage

Source: Internet
Author: User
Keywords We name save upload
Tags access application audio and video binary block class cloud create
The previous article is about the table storage of Azure Service, this article is mainly aimed at the other kind of special storage-binary in azure, such as unstructured storage, if our Azure services need to save non-traditional or structured data, such as pictures, audio and video media, etc. Then we need to use the BLOB storage. The Windows Azure platform provides a good hosting platform and programming model.

Blob storage differs from Azure table storage in terms of concept, before we see the most important concept of table storage is the concept of entity (Entity), in which entities contain attributes. corresponding to blob storage, the corresponding entity, the more important concept is the container (Container).

Rule 1:blob data is stored in containers, a container is a collection of BLOB data, a set of BLOB data is saved, and the container itself has a policy of shared read and private different access; Each container is associated with a metadata store object that records the properties associated with the BLOB data. ; Each container also has a list that records all BLOB data in the container.

The concept of BLOB storage containers is as follows:

Pictures source:ES04.pptx of PDC 2008-windows Azure storage–essential Cloud Storage Services

Account Sally There are two blob storage containers, a container called pictures, indicating that it is used to save the picture, and another container called movies, indicating that it is used to save video data. The pictures container contains two BLOB data, img001.jpg and img002.jpg respectively.

The Blob storage container for the rule 2:azure is also followed and subordinate to an account number, an account below you can create multiple BLOB storage containers, as well as table-stored table names. The container name follows the name of the account, and you can see the rule from the rest path of the access:http://< Account>.blob.core.windows.net/<container>/<blobname>

As pictured above, the container pictures and movies are under the account of Sally, respectively.

The rule 3:blob data is stored in a different BLOB storage container, a BLOB data maximum capacity is 50G, and each BLOB data has a unique character mark in the container as the BLOB data name. Each BLOB data can have a description of the attribute associated with it, and each attribute is a name-value pair that is stored in the container's metadata, in a container where the associated attribute size of the BLOB data cannot exceed 8K

As pictured above, img001.jpg,img002.jpg and Mov1.avi are BLOB data stored separately in different containers, and img001.jpg is its BLOB data name.

Integrated Rule 1,2,3, for: Http://sally.blob.core.windows.net/music/rock/rush/xanadu.mp3 Such an access indicator, account name (accounts) is: Sally, Blob storage container name (Container) is: Music,blob data name (blobname) is: Rock/rush/xanadu.mp3

Rule 4: Upload a BLOB data to a BLOB storage container, if the size of a upload of more than 64M, you have to do a Blocks, such as a 10G movie, you can be divided into 2,500 blocks, each block 4M size, for continuous upload. After chunking, each block has a unique number or block name that marks the block.

There are a lot of rules and operating scenarios and design points related to chunking that are not discussed in this article too much.

Next, let's take a look at how to define the programming techniques for BLOB data containers and BLOB data access and access. Practice, I chose Jim Nakashima's article Windows Azure walkthrough:simple Blob Storage Sample as an experiential content.

This exercise is primarily familiar with the creation and access programming model of BLOB data, which is followed by the following diagram:

This application is similar to a download site, you can upload files to the Azure blob storage, for each uploaded file, upload the same time, you can add and file-related attributes, save it to the container's metadata. After uploading, we will query the BLOB storage container, or we can delete the BLOB data in the container operations processing. Basically, all the relevant concepts and concepts of rule 1, Rule 2 and Rule 3 are covered.

Because Jim Nakashima's article has the very detailed operation procedure, I have not discussed the operation step, but introduces the key processing process.

The Blob storage access API for Azure services still employs the Storageclient class library in the SDK, which is in the Storageclientlib directory of the Azure SDK. The previous series of articles has repeatedly explained how to increase storageclient.

Querying and creating BLOB storage containers using Getblobcontainer and CreateContainer

1:storageaccountinfo AccountInfo = Storageaccountinfo.getdefaultblobstorageaccountfromconfiguration ();

2:

3://Container names have the Mahouve restrictions as DNS names

4:

5:blobstorage blobstorage = blobstorage.create (AccountInfo);

6:

7: _container = Blobstorage.getblobcontainer (rolemanager.getconfigurationsetting ("containername"));

8:

9://returns False if the container already exists//make the container public so we can hit

10:

One://The URLs from the Web

12:

_container.createcontainer (New NameValueCollection (), containeraccesscontrol.public);

14:

Add BLOB data-related properties when uploading (blobproperties)

1://Make a unique BLOB name

2:

3:string extension = System.IO.Path.GetExtension (fileuploadcontrol.filename);

4:

5:blobproperties properties = new Blobproperties (Guid.NewGuid (). ToString () + extension);

6:

7://Create metadata to is associated with the Blob

8:

9:namevaluecollection metadata = new NameValueCollection ();

10:

11:metadata["FileName"] = Filenamebox.text;

12:

13:metadata["Submitter"] = Submitterbox.text;

14:

15:properties. Metadata = Metadata;

16:

17:properties. ContentType = FileUploadControl.PostedFile.ContentType;

18:

Create The Blob

20:

21:blobcontents Fileblob = new Blobcontents (fileuploadcontrol.filebytes);

22:

_container.createblob (Properties, Fileblob, true);

24:

Use the Listblobs method to read BLOB data in a container, and enumeration-related properties (blobproperties)

1:ienumerable<object> blobs = _container.listblobs (string. Empty, false);

2:

3:list<fileentry> fileslist = new list<fileentry> ();

4:

5:foreach (Object o in BLOBs)

6:

7: {

8:

9:blobproperties BP = o as blobproperties;

10:

11:IF (BP!= null)

12:

13: {

14:

15:blobproperties p = _container.getblobproperties (BP. Name);

16:

17:namevaluecollection fileentryproperties = P.metadata;

18:

19:fileslist.add (New Fileentry, P.name, BP. Uri, fileentryproperties["FileName"], fileentryproperties["submitter"));

20:

21:}

22:

23:}

24:

25:fileview.datasource = fileslist;

26:

Remove specific BLOB data using the Deleteblob method

1:if (_container.doesblobexist (blobname))

2:

3: {

4:

5: _container.deleteblob (blobname);

6:

7:}

8:

From the experience above we can still find that when we master the design concepts and rules of the azure blob and use the Storageclient class library as a client for Azure service storage, we can manipulate the various storage types of azure services.

We also found that the various storage of azure services is very flexible and close to the application scenario, BLOB storage operations and table storage are more focused on how to save BLOB data and associated attributes rather than letting developers think about creating BLOB data tables; Blob storage does not emphasize specific retrieval performance in queries, but more provides the ability to upload and download unique blob storage.

In addition, as the client of Azure service storage, the Storageclient class library is exploited by many developers to create many gadgets. Like the newest Azureblobsync gadget.

We can use this tool to upload local files to a BLOB storage container in one of our cloud accounts, as well as to download a file from the cloud to a local computer directory. Above, we use this tool to upload and download files to the apps we just made.

Using the Web role of the application we just wrote, we can also query the files we uploaded using Azureblobsync.

Of course, because Azureblobsync does not define and manipulate the attributes (metadata) of BLOB data, the files we upload are not related to attributes. But we can still manipulate it because it's in a BLOB storage container.

We can also see the storage format for BLOB storage from the SQL Server database

With these tools and SQL database observations, we have a clearer and more familiar design for blob storage so that I can easily apply it to azure service programming.

Also, we can use another gadget, Azure Storage Explorer, to view the various storage types of azure services, such as table storage, queue storage, blob storage, and querying, deleting, and other operations on the data inside.

To sum up, we can make a small summary of Azure's various storage-type features and uses:

· Azure BLOB Storage – provides binary storage services for pictures, videos, files, and large chunks of data

· Azure Table Storage-mainly provides structured storage for keeping Azure with relevant state management, business data, user data, etc.

· Azure Queue Storage-primarily provides a reliable message store and messaging service for notification of asynchronous tasks and communication between services.

· Azure Localstorage Storage-primarily provides temporary storage of a separate file system for recording and saving temporary data.

Relevant demo code can be obtained at download. The code is tested through the azure SDK and Tools in the 2009 CTP environment.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.