Question

I'm pretty new in Azure and I want to create a simple .Net application (in C#) with one web role and one worker role to upload and resize images. I've already made a galery in the web role. It creates a blob then uploads the pictures there, then shows them.

What I want to do now: Sending a message throw a queue to a worker role if any of the pictures are too big then resize them in the worker role. My promblem is that I can't see how to access the same blob which was created in the web role (first I want to access to it in the local development emulator). If I add a new entry in the worker roles properties --> settings page that will give me a completely different blob connection string, doesn't it?

Thanks for any help.

Was it helpful?

Solution

In order to access the same storage account from multiple roles you will need to add the connection string to all roles in the cloud project:

enter image description here

To initialize the client you would write something like this (again, this will be the same on all your roles):

CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
    CloudConfigurationManager.GetSetting("MyStorageAccount"));

Whenever your Web Role sends a message to the queue to notify a Worker Role that the image should be resized, simply include the url or the container name + blob path. With this information your Worker Role will be able to fetch the blob and do the required processing.

I suggest you take a look at the official Windows Azure Training Kit. One of the hands on labs does exactly what you're trying to do here with a Guestbook application (uploading an image on a Web Role, creating a thumbnail in a Worker Role, ...): HOL-IntroToCloudServices Ex2-UsingWorkerRolesAndQueues

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