【Azure Developer】使用JavaScript通过SDK进行monitor-query的client认证报错问题

简介: AADSTS90002: Tenant 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' not found. Check to make sure you have the correct tenant ID and are signing into the correct cloud. Check with your subscription administrator, this may happen if there are no active subscriptions for the tenant.

问题描述

使用JavaScript通过SDK进行monitor-query的client初始化时候,需要进行认证时报错AADSTS90002。

代码如下:

const credential = new DefaultAzureCredential();
const logsQueryClient = new LogsQueryClient(credential , {
    endpoint: "https://api.loganalytics.azure.cn/v1"   
    ,audience: "https://api.loganalytics.azure.cn/.default",
  });

截图如下:

报错如下:

2024-06-26 16:26:05 [error] AuthenticationError: EnvironmentCredential authentication failed. To troubleshoot, visit https://aka.ms/azsdk/js/identity/environmentcredential/troubleshoot.

Status code: 400More details:invalid_request: 90002 -

[2024-06-26 08:26:05Z]: AADSTS90002: Tenant 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' not found. Check to make sure you have the correct tenant ID and are signing into the correct cloud. Check with your subscription administrator, this may happen if there are no active subscriptions for the tenant.

Trace ID: xxxxxxxx-hgef-dre9-xxxx-xxxxxxxxxxxx

Correlation ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

Timestamp: 2024-06-26 08:26:05Z -

Correlation ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -

Trace ID: xxxxxxxx-hgef-dre9-xxxx-xxxxxxxxxxxx

at (/code/node_modules/@azure/identity/dist/index.js:3673:49) at processTicksAndRejections (node:internal/process/task_queues:96:5)

at withSpan (/code/node_modules/@azure/core-tracing/dist/commonjs/tracingClient.js:36:28)

at (/code/node_modules/@azure/identity/dist/index.js:3340:29)

at withSpan (/code/node_modules/@azure/core-tracing/dist/commonjs/tracingClient.js:36:28)

at getToken (/code/node_modules/@azure/identity/dist/index.js:3330:27)

at tryGetAccessToken (/code/node_modules/@azure/core-rest-pipeline/dist/commonjs/util/tokenCycler.js:36:32)

at beginRefresh (/code/node_modules/@azure/core-rest-pipeline/dist/commonjs/util/tokenCycler.js:44:17)

at defaultAuthorizeRequest (/code/node_modules/@azure/core-rest-pipeline/dist/commonjs/policies/bearerTokenAuthenticationPolicy.js:21:25)

at sendRequest (/code/node_modules/@azure/core-rest-pipeline/dist/commonjs/policies/bearerTokenAuthenticationPolicy.js:72:13)

{

statusCode: 400,

errorResponse:

{

error: 'EnvironmentCredential authentication failed. To troubleshoot, visit https://aka.ms/azsdk/js/identity/environmentcredential/troubleshoot.',

errorDescription: "invalid_request: 90002 - [2024-06-26 08:26:05Z]: AADSTS90002: Tenant 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' not found. Check to make sure you have the correct tenant ID and are signing into the correct cloud. Check with your subscription administrator, this may happen if there are no active subscriptions for the tenant. Trace ID: xxxxxxxx-hgef-dre9-xxxx-xxxxxxxxxxxx Correlation ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx Timestamp: 2024-06-26 08:26:05Z - Correlation ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx - Trace ID: xxxxxxxx-hgef-dre9-xxxx-xxxxxxxxxxxx",

correlationId: undefined,

errorCodes: undefined,

timestamp: undefined,

traceId: undefined

}

}

问题解答

经过对JS SDK源码的分析,最后Azure Monitor团队找到了原因,是需要指定正确的Audience,正确的值为:audience: "https://api.loganalytics.azure.cn"。修改Audience后JS代码可以在中国区正常运行。

 

原代码

const logsQueryClient = new LogsQueryClient(credential , {
    endpoint: "https://api.loganalytics.azure.cn/v1"   
    ,audience: "https://api.loganalytics.azure.cn/.default",
  });

改为:

const logsQueryClient = new LogsQueryClient(credential , {
    endpoint: "https://api.loganalytics.azure.cn/v1"   
    ,audience: "https://api.loganalytics.azure.cn",
  });

 



当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!

目录
打赏
0
1
1
0
203
分享
相关文章
【Azure Developer】编写Python SDK代码实现从China Azure中VM Disk中创建磁盘快照Snapshot
本文介绍如何使用Python SDK为中国区微软云(China Azure)中的虚拟机磁盘创建快照。通过Azure Python SDK的Snapshot Class,指定`location`和`creation_data`参数,使用`Copy`选项从现有磁盘创建快照。代码示例展示了如何配置Default Azure Credential,并设置特定于中国区Azure的`base_url`和`credential_scopes`。参考资料包括官方文档和相关API说明。
mapbox没有token/token失效,地图闪烁后变空白,报错Error: A valid Mapbox access token is required to use Mapbox GL JS.
本博客介绍了mapbox如何去除token验证,暴力破解mapbox的token验证机制。一劳永逸解决mapbox地图闪现一下然后变成空白,报错Error: A valid Mapbox access token is required to use Mapbox GL JS.的方法,还介绍了类似问题的具体解决思路。 只有锻炼思维才能可持续地解决问题,只有思维才是真正值得学习和分享的核心要素。如果这篇博客能给您带来一点帮助,麻烦您点个赞支持一下,还可以收藏起来以备不时之需,有疑问和错误欢迎在评论区指出~
【Azure Storage Account】利用App Service作为反向代理, 并使用.NET Storage Account SDK实现上传/下载操作
本文介绍了如何在Azure上使用App Service作为反向代理,以自定义域名访问Storage Account。主要内容包括: 1. **设置反向代理**:通过配置`applicationhost.xdt`和`web.config`文件,启用IIS代理功能并设置重写规则。 2. **验证访问**:测试原生URL和自定义域名的访问效果,确保两者均可正常访问Storage Account。 3. **.NET SDK连接**:使用共享访问签名(SAS URL)初始化BlobServiceClient对象,实现通过自定义域名访问存储服务。
【Azure App Service】在App Service中调用Stroage SDK上传文件时遇见 System.OutOfMemoryException
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
【08】flutter完成屏幕适配-重建Android,增加GetX路由,屏幕适配,基础导航栏-多版本SDK以及gradle造成的关于fvm的使用(flutter version manage)-卓伊凡换人优雅草Alex-开发完整的社交APP-前端客户端开发+数据联调|以优雅草商业项目为例做开发-flutter开发-全流程-商业应用级实战开发-优雅草Alex
【08】flutter完成屏幕适配-重建Android,增加GetX路由,屏幕适配,基础导航栏-多版本SDK以及gradle造成的关于fvm的使用(flutter version manage)-卓伊凡换人优雅草Alex-开发完整的社交APP-前端客户端开发+数据联调|以优雅草商业项目为例做开发-flutter开发-全流程-商业应用级实战开发-优雅草Alex
202 20
【08】flutter完成屏幕适配-重建Android,增加GetX路由,屏幕适配,基础导航栏-多版本SDK以及gradle造成的关于fvm的使用(flutter version manage)-卓伊凡换人优雅草Alex-开发完整的社交APP-前端客户端开发+数据联调|以优雅草商业项目为例做开发-flutter开发-全流程-商业应用级实战开发-优雅草Alex
[Android][Framework]系统jar包,sdk的制作及引用
[Android][Framework]系统jar包,sdk的制作及引用
193 0
|
4月前
|
Android SDK
【10月更文挑战第21天】
165 1
Android|使用阿里云推流 SDK 实现双路推流不同画面
本文记录了一种使用没有原生支持多路推流的阿里云推流 Android SDK,实现同时推送两路不同画面的流的方法。
107 7

热门文章

最新文章