For a UI feature, I need to read from a Windows Azure queue and update the UI accordingly.
I see plenty of node.js examples, but nothing using pure Javascript or Jquery. (azureQuery comes close, but no queue functionality yet and it needs a Web API to talk to)
This is a hybrid web app using both asp.net and MVC 4. This particular page is generated using MVC 4.
Any suggestions would be appreciated.
Roberto
(PS. being able to write to the queue would also be nice)
This isn't possible directly from the browser. JavaScript in the browser has to follow the same-origin policy, which means that JavaScript can only make calls to the domain of the current web page. Since your web page won't be served from <account>.queue.windows.net
, it means your JavaScript won't be able to call APIs on that domain. (This would be possible in most browsers if the queue service served up CORS headers, but it doesn't.)
You'll need to host a web endpoint (in your MVC 4 app, probably) that proxies queue messages. Your JavaScript will send a message to your web app, and your web app will put the message on the queue.
UPDATE: Please see comments below and discard this answer.
You can try fetching the list of messages using shared access signature (SAS) for queues. I just did a simple test where I created a SAS for queue with "Read" Permission. I get a URI something like this:
youraccount.core.queue.net/queuename?sv=2012-02-12&st=2012-10-11T04%3A31%3A53Z&se=2012-10-11T05%3A31%3A53Z&sp=raup&sig=PN4dyOoOIBlJPQbQ%2Bu7jDLyt%2FpIc3k2k1NZTei6q7Cg%3D
Using this I created a URI for peeking messages
youraccount.core.queue.net/queuename/messages?sv=2012-02-12&st=2012-10-11T04%3A31%3A53Z&se=2012-10-11T05%3A31%3A53Z&sp=r&sig=PN4dyOoOIBlJPQbQ%2Bu7jDLyt%2FpIc3k2k1NZTei6q7Cg%3D&peekonly=true
I then used this URI in my JavaScript code and traced the request in Fiddler. I was able to see response coming back from Windows Azure Storage.
You can access Windows Azure Queue over REST interface using any supported language. With JavaScript your can make ajax calls to connect with Azure Storage Queue to read and write messages. Once you have JavaScript + Ajax based code in your hand, you just need to use Azure Queue Storage REST API to perform any operation.
Here is a sample using JavaScript to connect Azure Storage Queue. You can modify the code to connect to your real Azure Storage queue and it will fulfill your need: