Windows Azure blob storage & URL rewrite - azure

What I need is to rewrite URL for the requested blob, i.e. instead of
http://myaccount.blob.core.windows.net/clients/{client-name}/images/imagefile.jpg
should be served
http://myaccount.blob.core.windows.net/clients/images/imagefile.jpg
The client name in the URL is a request to have SEO URL, as file names are unique and I'd like to have blob name as
images/imagefile.jpg instead of
{client-name}/images/imagefile.jpg and use something like URL rewrite in IIS.
It becomes a pain if the client changes it's name as I can't rename a blob I have to create copy and delete the old blob. It may take more than a minute which we can't afford.

You can't use anything like URL Rewrite for the storage accounts. You can only have custom domain mapped to your storage account. For example instead of referencing blobs with: http://myaccount.blob.core.windows.net/... you could map them to http://img.yourdomain.com/... And you could also use the Azure CDN for better performance and user experience!
Moreover, if you do care about SEO, you have to also think on not just "rename" the blob but also use HTTP 301 redirect from the old blob to the new one. Which also is impossible with Azure storage service. I suggest that you use client-id instead of client-name
UPDATE
You "can" reanme the blobs, simialry to the way you would rename files. Given your requirement - if you want to "quickly" rename a lot of images, you have to write simple "service" anyway, because I can't figure out another way to rename 1000s of files on the file system either. With the blobs, although beeing remote it will be almost the same. And you are wrong that you have to save the blob on the machine. There is new feature (method on the CloudBlob instance) since November'2011 release (I think), named CopyFromBlob. Here is an example of how to rename blobs.. This way you can easily move blobs even around different account without the need to first download the content. Yes, it may take a bit longer than with a local file system. But still this is a fair-enough solution.
Think about what the Azure Storage is. A massively scalable, reliable storage as a service. You have 100TB (subject to increase if required), with 3 copies locally + one copy in another geo region. A CDN support for this massive storage with more than 24 nodes worldwide. I don't think renaming is something of top need.

Related

Can Azure Blob storage container name be made case insensitive?

We have a picture server with lots of files serving the files over http. They are currently accessed through urls with the format
http://pictures.example.com/Pictures/xx/yyyyyy/zzzzzzzzzzzzzzzzzzzzzzzzzzzzz.jpg
We have a plan to move them to Azure blob storage and since the urls to the current pictures are used in several external systems we would like to keep the urls identical.
In Azure Blob storage the first part of the blob url is the name of the container. Our existing urls are named Pictures/xxx. Container names can, however, only have lowercase letters.
Do I have to create an Azure App Service just for url redirection or is there some way around this?
Blob containers must be lower-case. Blob names can be mixed case.
There is no workaround to this, as it's part of the service.
You mentioned creating an app service for url redirection. Note that, if you choose to access your blobs directly, vs through your app service, you will not be able to perform any redirection.
More info on naming rules here.

Best Way to host dynamic image with Azure

I am working on a website where I need to dynamically host images. My intention is to host the images with full URL.
I tried CDN but come to know it has a limitation of that image will only be available 15 mins after upload.
Other options is Blob storage, when I read the document it says "Block blobs" are most ideal for image and media content. Therefore, I am trying to use that.
So, I've following questions:
What is the best way to host images on Azure for such requirements?
If I use Blob storage then how can I get the full URL so that I can that URL to load images in my product?
There really isn't a best way to store images. Some people store them in blob storage (as you referenced), some go with database engines... But, since you asked specifically about how to interact with blob storage and URI's:
All blobs are referenced by uri: http(s)://storagename.blob.core.windows.net/containername/blobname
You can set every blob to private or public (whether at blob or container level), and then either return URI's to your user/webpage (if public) or generate a Shared Access Policy or Shared Access Signature to temporariliy grant access to a private blob (I'll leave that as an exercise for you to look up).
It's completely up to you to create containers and blobs as needed. How you find a blob later is also up to you, so you'll need to think about how you store their names or their URIs (e.g. in a database table somewhere). You can always iterate through containers to search for a given blob, but that is time-consuming, vs direct-retrieval (again, assuming you've stored the URI as metadata somewhere in a database).

Can we do manipulation with Data stored in Azure Storage directly through VM without downloading it on VM?

I had some data that is stored on Azure Storage which is in compressed form and i want to decompress it so is it possible that i could decompress it without downloading it on the Virtual Machine. I mean to say that the storage could work in the same manner as my Secondary storage device does. Ask if you need more detail.
The answer is always "depends".
If it is possible - yes. Do you really want to do it - I am not sure.
Take the Blob Storage, because I assume you store your data in a blob storage. There are two different types of Blobs - Block Blobs and Page Blobs. Either can be updated by partially updating its content.
When having a block blob you can modify it using the Put Block operation on the Storage API. When you have a page blob, you can use the Put Page operation on the Blob Service API.
Of course after modifying the content you will have to send a final request to the Blob Service API to "commit" the changes and inform the service about the new content (Put Block List for BlockBlobs and implement robust retry logic for Put Page for Page blobs).
Although technically it is possible to manipulate the content on the blob without downloading the whole file, it really brings more complications than it solves. For example - once you modify part of the content of a file, all the checksums are now broken. Moreover - if it is a compressed file, you also have to modify the header of the file. At the end - if you know the exact structure of what you saved and you know which exact parts of it you want to modify - you can do it. But I think it will be just overengineering.

Change FileName Download from Azure

I using Azure Shared Access Signature to create Url to redirect download from my Azure, problem is when download is using Original Name of File, I want to change filename when user download to client.
Anyone have solution.
Thanks
p/s: my Container on Azure is Private permission and I using Asp.net MVC 4
Blobs cannot be renamed or aliased. The only thing you can change is the base dns name (which you can map to a custom name).
That said: If you really wanted to present a unique blob for download and not use the current name, you could make a blob copy (a very fast operation within the same data center) to the name you desire, and then offer up a Shared Access Signature to that new blob. After a reasonable amount of time (maybe just beyond expiration of the SAS), you could then delete the extra blob.

Where to store things like user pictures using Azure? Blob Storage?

I have just migrated a project of mine for test cases to Microsoft's azure.
But for functionalities similar to an avatar upload I need write access to the files on the harddrive. But this is a cloud, so this is not possible.
How can I build such functionalities instead? Should I use the Blob Storage or is there a better solution?
Does it make sense to store all website images (f.e. layout images) in the Blob Storage? So I would have a Cookie-free Domain for my static content?
Blob storage is definitely the place to put dynamic images like avatars. While you can write to the disk on the VM you'll be running in, you can't rely on this to be present - if your app gets moved off to another machine (which could happen for any number of reasons) this storage will be erased.
One thing you could do is store your images in blob storage, and cache them on the local VM disk (using the standard file IO mechanisms). This way you'll get pretty good performance and will save on a few storage transactions while still making sure you're not storing in volatile storage.
If you've got static images which will be completely static, these are just bundled with your application and can be referenced like a normal file. But, if you will ever need to change them, you'd need to redeploy the application - so only use this technique for images which won't need to change.
Be aware there are two types of Blobs in Windows Azure: Block Blobs and Page Blobs. Block Blobs are appropriate for media file serving, whereas Page Blobs are optimized for other work patterns.
Also consider use of the Azure Content Distribution Network (CDN) for lowering latency to clients.
Azure also has streaming capabilities which work in concert with Silverlight Smooth Streaming (http://blog.smarx.com/posts/smooth-streaming-with-windows-azure-blobs-and-cdn if interested).
"Does it make sense to store all website images (f.e. layout images) in the Blob Storage? So I would have a Cookie-free Domain for my static content?"
Yes I think so - this is what I'm rolling out right now actually.

Resources