我可以使用JavaScript调用Azure管理REST API? [英] Can I use Javascript call the Azure management REST API?

查看:149
本文介绍了我可以使用JavaScript调用Azure管理REST API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在JavaScript中使用的Azure表存储REST API。
所以我做这样的电话:

I want to use Azure Table storage REST api in javaScript. So I make call like this:

 $.ajax({
        type: "POST",

        beforeSend: function (request)
        {
            request.setRequestHeader("contentType", "application/atom+xml;type=entry;charset=utf-8");
        },
        url: "http://mystorageaccountname.table.core.windows.net/TodoList()?sv=2012-02-12&se=2013-07-05T09%3A40%3A06Z&tn=Todo&sp=raud&spk=myid&epk=myid&sig=Z%2BrfC2HxxxBUqM3nt6sCjlSvttb6qqOY%2BBnbdPYV%2BzliA%3D&timeout=90",
        contentType: "application/atom+xml",
        dataType: "jsonp",
        jsonpCallback:"jsonpCallback",
        data: xmlString,
        success: function (xhr) {
            alert(xhr.statusCode);
        }   
    });

我发现请求类型转换得到,因为JSONP不支持后..
后来我发现这个主题:

I found the request type convert to get because jsonp not support post.. Then I found this threads:

<一个href=\"http://stackoverflow.com/questions/12788350/how-to-upload-a-text-string-directly-to-windows-azure-blob-from-the-browser-usin\">How从浏览器使用JavaScript 直接上传文本字符串到Windows Azure的Blob
<一href=\"http://stackoverflow.com/questions/12827059/accessing-windows-azure-queues-from-client-side-javascript-jquery\">Accessing从客户端的JavaScript / jQuery的

How to upload a text string directly to Windows Azure Blob from the browser using javascript Accessing Windows Azure Queues from client side javascript/jquery

好像如果我的主机与同域webrole和tablestorage服务,我可以使用code。与数据类型= XML。

seems like if I host the webrole and tablestorage service with the same domain, I can use that code with datatype=xml.

我怎样才能做到这一点?
是否
akakin.appcloudapp.net
akakin.table.core.windows.net
是同一个域?
或者我如何使用JS / JQuery的直接调用Azure的管理CHINESE REST API?

How can I do that? Does akakin.appcloudapp.net akakin.table.core.windows.net is same domain? Or how can I use JS/JQuery call Azure mangement Rest API directly?

推荐答案

目前无法使用JavaScript调用Azure管理API,直接因为CORS是不是在Windows Azure的支持。针对CORS的支持在Windows Azure存储即将到来。除了CORS,Windows Azure的表的存储还将支持JSON格式返回数据。一旦这些两件事都很到位,你应该能够做到这一点。

Currently you can't call Azure Management API directly using JavaScript because CORS is not supported in Windows Azure. Support for CORS is coming soon in Windows Azure Storage. Apart from CORS, Windows Azure Table Storage will also support returning the data in JSON format. Once those 2 things are in place, you should be able to accomplish this.

现在你需要依靠某种中间层(无论是作为Windows Azure云服务或Windows Azure的网站),到你通过你的JavaScript应用发送请求,然后这个中间层将与互动存储获取数据。由于Windows Azure的表的存储只返回XML格式的数据,你会然后将这些数据转换成JSONP格式,并返回给客户端。

For now you would need to rely on some kind of middle layer (either as a Windows Azure Cloud service or a Windows Azure Websites) to which you'll send requests through your JavaScript application and then this middle layer will interact with the storage to get the data. Since Windows Azure Table Storage only returns the data in XML format, you would then convert that data into JSONP format and return back to the client.

这篇关于我可以使用JavaScript调用Azure管理REST API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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