【发布时间】:2019-02-27 16:23:55
【问题描述】:
我正在尝试使用 node.js 通过以下示例代码访问 azure 资源管理器:
msRestAzure.interactiveLogin(function(err, credentials) {
if (err) console.log(err);
var client = new resourceManagement.ResourceManagementClient(credentials, 'token');
client.resources.list(function(err, result) {
if (err) console.log(err);
console.log(result);
});
});
运行时出现以下错误:
{ Error: The access token is from the wrong issuer 'https://sts.windows.net/token/'. It must match the tenant 'https://sts.windows.net/token/' associated with this subscription. Please use the authority (URL) 'https://login.windows.net/token' to get the token. Note, if the subscription is transferred to another tenant there is no impact to the services, but information about new tenant could take time to propagate (up to an hour). If you just transferred your subscription and see this error message, please try back later.
at client.pipeline.error (D:\azure-arm\node_modules\azure-arm-resource\lib\resource\operations\resources.js:496:19)
at retryCallback (D:\azure-arm\node_modules\ms-rest\lib\filters\systemErrorRetryPolicyFilter.js:89:9)
at retryCallback (D:\azure-arm\node_modules\ms-rest\lib\filters\exponentialRetryPolicyFilter.js:140:9)
at D:\azure-arm\node_modules\ms-rest\lib\filters\rpRegistrationFilter.js:59:14
at handleRedirect (D:\azure-arm\node_modules\ms-rest\lib\filters\redirectFilter.js:39:9)
at D:\azure-arm\node_modules\ms-rest\lib\filters\formDataFilter.js:23:14
at Request.defaultRequest [as _callback] (D:\azure-arm\node_modules\ms-rest\lib\requestPipeline.js:125:16)
at Request.self.callback (D:\azure-arm\node_modules\request\request.js:185:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
任何你看到令牌的地方,我都替换了那里的实际值。我提供的订阅 ID 是正确的。我试过直接登录而不是使用上面的密钥,它具有相同的效果。理想情况下,我们希望 azure 中的应用程序能够访问 arm API,但在活动目录中似乎不可能,而且我似乎无法让它工作。任何帮助将不胜感激。
【问题讨论】:
标签: node.js azure azure-resource-manager