【Azure Spring Cloud】Spring Cloud Azure 4.0 调用Key Vault遇见认证错误 AADSTS90002: Tenant not found.

问题描述

Spring Cloud Azure 4.0 调用 Key Vault 的代码中,没有找到设置 authority-host 的配置项,导致认证出现错误

Caused by: com.microsoft.aad.msal4j.MsalServiceException: 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-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Correlation ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

 

问题解释

以上错误是在参考文档“从 azure-spring-boot-starter-keyvault-secrets 到 spring-cloud-azure-starter-keyvault-secrets” 完成迁移后,无法访问 Key Vault 了. 提示 Tenant_id 无效, 可能登入的不正确的 Cloud. 因为在迁移前,登录的为中国区Azure AAD,而修改后,因为没有找到指定 authority-host 为 https://login.partner.microsoftonline.cn 的配置项,所以默认的认证host变为 Global Azure,所以提示Tenant Id 无效。

 

解决方式

Azure Spring 4.0中对于China Azure做了很多配置项,可以在全局指定,也可以在服务中指定。

如果在 spring.cloud.azure.keyvault.secret.property-source[n]….. 中,可以尝试以下配置:

  1. spring.cloud.azure.keyvault.profile.cloud-type: azure_china
  2. spring.cloud.azure.keyvault.secret.profile.environment.active-directory-endpoint: https://login.partner.microsoftonline.cn

 

参考资料

4.0 迁移指南 : https://learn.microsoft.com/zh-cn/azure/developer/java/spring-framework/spring-cloud-azure-appendix#migration-guide-for-40
azure-spring-boot-starter-keyvault-secrets 到 spring-cloud-azure-starter-keyvault-secrets : https://learn.microsoft.com/zh-cn/azure/developer/java/spring-framework/spring-cloud-azure-appendix#sdk-configuration-changes-3
 
posted @   路边两盏灯  阅读(245)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
历史上的今天:
2021-10-20 【Azure Developer】如何验证 Azure AD的JWT Token (JSON Web 令牌)?
2020-10-20 【应用服务 App Service】App Service发生错误请求时,如何查看IIS Freb日志,从中得知错误所发生的模块,请求中所携带的Header信息
点击右上角即可分享
微信分享提示