I'm new to Azure and trying out the tutorial here.
The tutorial is about creating a Cloud Service on Azure taking advantage of the Web Role delegating task to the Worker Role. The only part that matters; when user uploads an image to the Web Role, the Web Role will put the image in Azure Storage and create a new record in the database with a field containing the URL of the stored image. The Web Role next places a message (the ID of the newly added record) in Azure Queue.
var queueMessage = new CloudQueueMessage(id);
await _cloudQueue.AddMessageAsync(queueMessage);
The Worker Role will then retrieve the message from the queue. Next, retrieve the record from the database. Then create a thumbnail from the image url of the retrieved database record.
while (true) {
var msg = _cloudQueue.GetMessage();
if (msg != null) {
CreateThumbnail();
}
System.Threading.Thread.Sleep(1000);
}
The tutorial offers guidance to
- download the solution source files and open from Visual Studio
- or create the solution from scratch using Visual Studio
The solution works fine when using the downloaded source files. In the Worker Role, var msg = _cloudQueue.GetMessage();
.
msg
always has something (not null) albeit there's a delay of 3 to 4 seconds after the image is uploaded. Therefore CreateThumbnail()
is always executed 3 to 4 seconds after the image is uploaded.
However, if I were to create the solution from scratch, msg
is always null no matter how long I waited and CreateThumbnail
was never executed. I made sure the Worker Role was indeed running by putting breakpoint here and there.
The source of the problem
After a few painstaking hours, I have boiled the problem down to the assembly Microsoft.WindowsAzure.Storage
.
The solution source files downloaded from the tutorial page is using version 3.2.0 while the solution created from scratch is using the latest version 5.0.0 from NuGet. So in order words, msg
is always null if I'm using the latest version 5.0.0 of Microsoft.WindowsAzure.Storage
on the Worker Role. Is this a known issue or am I missing something.