Domanda

I'm running 2 azure instances on my cloudservice that is hosting a website.

I upload a file to a folder and it's saved in one of the instances. When I try to load it, if azure chooses the wrong instance, it doesn't find the file. What options do I have to solve this?

I thought in saving the files in a blob storage but if I could keep it this way it would save me some time.

È stato utile?

Soluzione

As you mentioned in your question, you should save it in blob storage. There are few reasons for that:

  1. Windows Azure by default uses round-robin load balancing policy. What that means is that if you upload the file in one instance and when a user requests the file if the request is served by 2nd instance the file won't be found (the error you're getting).
  2. More importantly, cloud services are stateless by nature. What that means is that anything you do on that VM (like saving files etc.) are gone once the VM goes down.

Blob storage, on the other hand is persistent storage and is accessible via simple http protocol. So when a user uploads a file, you save it in blob storage. When user requests it, you just serve the blob from blob storage.

UPDATE - BASED ON COMMENTS BELOW

Regarding your 1st comment, You can still use blob storage. What you could do is create a blob container to hold temporary files and once the user has completed all the steps, you could move them to another container (let's call it permanent container). For copying blobs from one container to another you don't even have to download the blobs to your VM. Windows Azure supports server side async copy which copies the blob from one container to another server side.

Regarding your 2nd comment, I don't think you can change the load balancing policy. There's something called Application Request Routing (ARR) which does implement sticky sessions but unfortunately I'm not familiar with it. You may want to look into it.

Altri suggerimenti

You are using VMs, right? If switching to Azure Websites was an option then your application files / images would be located on one shared network drive, always available to all your instances. http://azure.microsoft.com/en-us/documentation/videos/web-sites-internals-and-the-file-system/

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top