如何通过JavaScript访问Azure存储队列 [英] How to access Azure storage queue by JavaScript

查看:160
本文介绍了如何通过JavaScript访问Azure存储队列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关我们的测试目的,我们想访问Azure存储队列直接代替$ P $的JavaScript pparing一个新的Web服务。

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

这可能吗?我们应该做些什么来实现这一点,因为我无法找到Azure存储的API的JavaScript的官方文档。

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

推荐答案

是的,这当然是可能的。事实上,我目前正在开发这不正是这样的服务。

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

第1步:启用CORS的队列服务

要做到这一点,首先你需要在你的队列服务使CORS设置。您可能会发现CORS设置这个博客帖子有用:<一href=\"http://blogs.msdn.com/b/windowsazurestorage/archive/2014/02/03/windows-azure-storage-introducing-cors.aspx\" rel=\"nofollow\">http://blogs.msdn.com/b/windowsazurestorage/archive/2014/02/03/windows-azure-storage-introducing-cors.aspx.你将不得不作出下列设置:

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:

允许原产地:您正在访问的域名

允许的谓词:我将开始与所有可能的动词,但是做看看的 REST消息API文档 ,看你要执行,只允许那些动词哪些操作。

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.

允许标题:*

外露接头:*

第2步:获取一个共享访问签名的队列

接下来,您将需要在队列上创建一个共享访问签名(SAS),并设置相应的权限。有关队列设置SAS,你可以利用Azure存储客户端库。你会发现这个博客文章了解更多有关SAS在队列有用:<一href=\"http://blogs.msdn.com/b/windowsazurestorage/archive/2012/06/12/introducing-table-sas-shared-access-signature-queue-sas-and-update-to-blob-sas.aspx\" rel=\"nofollow\">http://blogs.msdn.com/b/windowsazurestorage/archive/2012/06/12/introducing-table-sas-shared-access-signature-queue-sas-and-update-to-blob-sas.aspx.

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.

第3步:访问您的队列

在SAS URL被创建,您可以采取的URL,并开始通过jQuery / AJAX Web应用程序中使用它。

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

这篇关于如何通过JavaScript访问Azure存储队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆