How to access Azure storage queue by JavaScript

只愿长相守 提交于 2020-01-13 05:38:21

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/24691018/how-to-access-azure-storage-queue-by-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!