簡體   English   中英

Azure資源管理器身份驗證失敗

[英]Azure Resource Manager Authentication Failure

我正在嘗試使用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,但在活動目錄中看起來不太可能,而且我似乎無法使它正常工作。 任何幫助,將不勝感激。

我已經使用了ms-rest-azure版本2.6.0和azure-arm-resource版本7.3.0,並且使用相同的代碼對我來說運行良好。

我認為使用服務主體身份驗證方式或基本身份驗證方式而不是交互式登錄身份驗證方式進行身份驗證是安全的。 我們在這里具有其他身份驗證方法的步驟-> https://github.com/Azure/azure-sdk-for-node/blob/master/Documentation/Authentication.md#using-authentication-in-your-您可以嘗試使用nodejs腳本

另外,由於您正在理想地尋找Azure中的應用程序以訪問ARM API,因此我認為值得閱讀以下文章-> https://docs.microsoft.com/zh-cn/azure/azure-資源管理器/資源管理器的API認證

希望這可以幫助!!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM