Tag: azure sqldw

身份validation问题 – 从Azure函数调用的Azure REST API

我正在使用Azure函数来调用Azure SQL数据仓库的其余API,以便在白天的特定时间暂停和恢复服务器(2个函数)。 在我之前创build的azure函数中,我从来不必调用REST API,因为我只使用可用的输出选项。 而SQL DW只有REST API选项。 我使用nodejs创build了一个函数应用程序,并从那里调用这些REST API。 我通过了azure色的REST API文档,并尝试了在那里解释的过程。 首先,我在azure活动目录中添加函数app作为租户,并获得tenantID(它是端点URL的一部分)和应用程序ID /客户端ID,然后尝试调用loginURL,如https:// docs.microsoft.com/en-us/azure/active-directory/active-directory-protocols-oauth-code#request-an-authorization-code通过传递所需的parameters.Though它被提及为GET,我试着GET和POST,他们没有工作。 module.exports = function(context) { var unirest = require('unirest'); var subscriptionId='subscriptionId'; context.log("starting the function"); unirest.post('https://login.windows.net/tenantID/oauth2/authorize') .headers({'Accept': 'application/json', 'Content-Type': 'application/json'}) .send({ "client_id": "clientID ", "response_type": "code","grant_type":"authorization_code" }) .end(function (response) { context.log(response.body); }); }); 这段代码只是为了获得authentication码,然后再有一个方法来获得令牌,然后调用实际的SQL DW暂停/恢复方法。 当我从VS2015运行相同的(删除模块导出和更改上下文到控制台),我得到如下相同的错误 <html><head><title>Continue</title></head><body><form method="POST" name="hiddenform" action="https://login.microsoftonline.com/9b8d9cda-ddb4-43bb-8725-bc0e9af83b43/oauth2/authorize"><noscript><p>Script is disabled. Click […]