Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access Azure storage queue by JavaScript

For our testing purpose, we would like to access Azure storage queue directly with JavaScript instead of preparing a new web service.

Is this possible? What should we do to achieve this, since I cannot find the official documentation for JavaScript API of Azure storage.

like image 660
Jerry Bian Avatar asked Aug 13 '26 02:08

Jerry Bian


1 Answers

Yes, it is certainly possible. In fact, I am currently developing a service which does exactly this.

Step 1: Enable CORS for Queue Service

To accomplish this, first you need to enable CORS settings on your Queue Service. You may find this blog post useful for CORS settings: http://blogs.msdn.com/b/windowsazurestorage/archive/2014/02/03/windows-azure-storage-introducing-cors.aspx. You would have to make following settings:

Allowed Origin: Your domain name

Allowed Verbs: I would start with all the possible verbs but do take a look at REST API documentation for messages and see which operations you wish to perform and allow only those verbs.

Allowed Headers: *

Exposed Headers: *

Step 2: Get a Shared Access Signature for Queue

Next, you would need to create a Shared Access Signature (SAS) on a queue and set appropriate permissions. For setting up SAS on Queues, you could make use of Azure Storage Client library. You may find this blog post useful for learning more about SAS on Queues: http://blogs.msdn.com/b/windowsazurestorage/archive/2012/06/12/introducing-table-sas-shared-access-signature-queue-sas-and-update-to-blob-sas.aspx.

Step 3: Access your Queue

Once SAS URL is created, you can take that URL and start using it via jQuery/AJAX in your web application.

like image 128
Gaurav Mantri Avatar answered Aug 15 '26 01:08

Gaurav Mantri



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!