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

简介: 【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

自 3.10.x 起的 4.0 中的新增功能 : https://learn.microsoft.com/zh-cn/azure/developer/java/spring-framework/spring-cloud-azure?tabs=maven#whats-new-in-40-since-310x

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

相关文章
|
10月前
|
监控 Java API
Spring Boot 3.2 结合 Spring Cloud 微服务架构实操指南 现代分布式应用系统构建实战教程
Spring Boot 3.2 + Spring Cloud 2023.0 微服务架构实践摘要 本文基于Spring Boot 3.2.5和Spring Cloud 2023.0.1最新稳定版本,演示现代微服务架构的构建过程。主要内容包括: 技术栈选择:采用Spring Cloud Netflix Eureka 4.1.0作为服务注册中心,Resilience4j 2.1.0替代Hystrix实现熔断机制,配合OpenFeign和Gateway等组件。 核心实操步骤: 搭建Eureka注册中心服务 构建商品
1414 3
|
8月前
|
负载均衡 Java API
《深入理解Spring》Spring Cloud 构建分布式系统的微服务全家桶
Spring Cloud为微服务架构提供一站式解决方案,涵盖服务注册、配置管理、负载均衡、熔断限流等核心功能,助力开发者构建高可用、易扩展的分布式系统,并持续向云原生演进。
|
Java 开发工具 Spring
【Azure Application Insights】为Spring Boot应用集成Application Insight SDK
本文以Java Spring Boot项目为例,详细说明如何集成Azure Application Insights SDK以收集和展示日志。内容包括三步配置:1) 在`pom.xml`中添加依赖项`applicationinsights-runtime-attach`和`applicationinsights-core`;2) 在main函数中调用`ApplicationInsights.attach()`;3) 配置`applicationinsights.json`文件。同时提供问题排查建议及自定义日志方法示例,帮助用户顺利集成并使用Application Insights服务。
397 8
|
负载均衡 Dubbo Java
Spring Cloud Alibaba与Spring Cloud区别和联系?
Spring Cloud Alibaba与Spring Cloud区别和联系?
|
存储 Java Spring
Spring Vault 2.1 正式发布
Spring Vault 2.1正式发布,需要JDK 8或更高版本,并且特别支持JDK 11作为下一个长期支持版本。提供熟悉的Spring抽象和客户端支持,用于访问、存储和撤销机密。
1697 0
|
11月前
|
Java Spring 容器
SpringBoot自动配置的原理是什么?
Spring Boot自动配置核心在于@EnableAutoConfiguration注解,它通过@Import导入配置选择器,加载META-INF/spring.factories中定义的自动配置类。这些类根据@Conditional系列注解判断是否生效。但Spring Boot 3.0后已弃用spring.factories,改用新格式的.imports文件进行配置。
1381 0
|
12月前
|
人工智能 Java 测试技术
Spring Boot 集成 JUnit 单元测试
本文介绍了在Spring Boot中使用JUnit 5进行单元测试的常用方法与技巧,包括添加依赖、编写测试类、使用@SpringBootTest参数、自动装配测试模块(如JSON、MVC、WebFlux、JDBC等),以及@MockBean和@SpyBean的应用。内容实用,适合Java开发者参考学习。
1249 0
|
前端开发 Java 数据库
微服务——SpringBoot使用归纳——Spring Boot集成Thymeleaf模板引擎——Thymeleaf 介绍
本课介绍Spring Boot集成Thymeleaf模板引擎。Thymeleaf是一款现代服务器端Java模板引擎,支持Web和独立环境,可实现自然模板开发,便于团队协作。与传统JSP不同,Thymeleaf模板可以直接在浏览器中打开,方便前端人员查看静态原型。通过在HTML标签中添加扩展属性(如`th:text`),Thymeleaf能够在服务运行时动态替换内容,展示数据库中的数据,同时兼容静态页面展示,为开发带来灵活性和便利性。
549 0
|
8月前
|
JavaScript Java Maven
【SpringBoot(二)】带你认识Yaml配置文件类型、SpringMVC的资源访问路径 和 静态资源配置的原理!
SpringBoot专栏第二章,从本章开始正式进入SpringBoot的WEB阶段开发,本章先带你认识yaml配置文件和资源的路径配置原理,以方便在后面的文章中打下基础
611 4

热门文章

最新文章