Question

Just starting to study the Azure framework.

Just say you create a row in the Table storage.

You then create a Bob in the Blob storage,

Is there some way you can correlate what you just added to the Table with the Blob you just created?

Or anytime you have related entries you must use SQL Azure?

That would be disappointing as say you wanted to store some Video in a blob, but had some row in an SQL Azure table that you wanted to link to the Blob.

Since you cannot have this link you must store your video in SQL Azure somehow?

Was it helpful?

Solution

You can store unique filename of file stored in blob into azure table row. Storing full video/binary content in Azure table or SQL azure table is not recommended as retrival will become bit slower and SQL azure is bit expensive compared to blob.

OTHER TIPS

As long as you choose your blob filename carefully, you should just be able to reference that filename in your Azure table. However, be careful how you name it. It is very tempting to jump in with a timestamp based name and reference that in the table. However, using Azure you are obviously using a scalable solution that can end up highly parallel.

Use a GUID for the filename to guarantee uniqueness. Or if you want to be able to more easily browse the storage based on when the items were added, perhaps choose a date format YYYYMMDDHHMMSS with a GUID suffixed to it.

It is perfectly possible and done many times, I personally implemented such an architecture for one of the projects I worked on.

I used Blob Name as Partition Key and Blob Container Name as Row Key for the entity I write to Table.

You can also do it other way around and choose Blob Container Name as PK and Blob Name as RK. Then you may want to consider the partitions in your table not getting too big and cause some perf issues down the road if your blob containers get too crowded.

There is one thing you need to explicitly handle though, Blob Name s and Blob Container Name s have different naming constraints then Table Partition Keys and Table Row keys, so you need to Sanitize the Blob Name and Blob Container Name and before using them as PK and RK and writing the entity to table or reading the entity from the table.

Here is how you can Sanitize Blob Name s and Blob Container Name s to be used as Table Keys:

public static readonly Regex DisallowedCharsInTableKeys = new Regex(@"[\#%/?\u0000-\u001F\u007F-\u009F]");

string sanitizedKey = DisallowedCharsInTableKeys.Replace(BlobName, disallowedCharReplacement);

At this stage you may also want to prefix the sanitized key (Partition Key or Row Key) with the hash of the original key (ie. Blob Name) to avoid false collisions of different invalid keys having the same sanitized value.

Azure supports associating metadata with the blobs. Metadata is essentially just name-value pairs. The following video might be useful: http://www.bestechvideos.com/2009/04/15/mix09-windows-azure-storage

So instead of associating the table with the blob, you might want to do the other way round by using metadata.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top