首页 > 其他分享 >【Azure Developer】Springboot 集成 中国区的Key Vault 报错 AADSTS90002: Tenant 'xxxxxxxx-xxxx-xxxx-xxxx-xx

【Azure Developer】Springboot 集成 中国区的Key Vault 报错 AADSTS90002: Tenant 'xxxxxxxx-xxxx-xxxx-xxxx-xx

时间:2022-12-30 17:58:30浏览次数:71  
标签:xxxx Springboot spring Azure secret 报错 azure cloud

问题描述

Springboot 集成azure keyvault 报错,代码参考的官方文档:https://docs.microsoft.com/en-us/azure/developer/java/spring-framework/configure-spring-boot-starter-java-app-with-azure-key-vault。 在运行时候,报错: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.

 

问题解答

通常遇见 tenant not found问题,就是Azure的环境设置不对引起的,因为参考的文档为Global Azure的代码,所以在配置Key Vault信息的时候,默认指向的是Global的Azure环境。

如在文章中的 “Add Key Vault configuration” 部署,只有 client-id, client-secret, endpoint, tenant 信息,没有配置 cloud-type=AZURE_CHINA 的信息,所以默认指向为Global Azure,所以存在China Azure中的Tenant当然在Global Azure中是无法发现的。

 

解决办法

在 src/main/resources/application.properties  配置文件中,添加  spring.cloud.azure.keyvault.secret.property-sources[0].profile.cloud-type=AZURE_CHINA 

如下图:

spring.cloud.azure.keyvault.secret.property-sources[0].credential.client-id=<your client ID>
spring.cloud.azure.keyvault.secret.property-sources[0].credential.client-secret=<your client key>
spring.cloud.azure.keyvault.secret.property-sources[0].endpoint=https://contosokv.vault.azure.cn/
spring.cloud.azure.keyvault.secret.property-sources[0].profile.tenant-id=<your tenant ID>
spring.cloud.azure.keyvault.secret.property-sources[0].profile.cloud-type=AZURE_CHINA 

 

即可成功解决问题!

 

参考资料

Read a secret from Azure Key Vault in a Spring Boot application : https://learn.microsoft.com/en-us/azure/developer/java/spring-framework/configure-spring-boot-starter-java-app-with-azure-key-vault#add-key-vault-configuration-to-the-app

标签:xxxx,Springboot,spring,Azure,secret,报错,azure,cloud
From: https://www.cnblogs.com/lulight/p/17015475.html

相关文章

  • SpringBoot - 获取参数 @PathVariable,@RequestParam,@RequestHeader,@RequestAttribute,@
    1.@PathVariable获取路径上的参数@RequestMapping(value="login/{id}")publicStringlogin(@PathVariable("id")intuserId){......} 2.@......
  • 执行shell脚本报错:Syntax error: word unexpected (expecting "in")
    可能是脚本文件换行符的问题。vs创建的文件默认以CRLF(0D0A)换行。然而对于换行,windows用CRLF(0D0A)表示,linux用LF(0A)表示。切换脚本文件换行符为LF(0A)后运行成功,如在vs中更改......
  • SpringBoot自定义注解+AOP+redis实现防接口幂等性重复提交,从概念到实战
    一、前言在面试中,经常会有一道经典面试题,那就是:怎么防止接口重复提交?小编也是背过的,好几种方式,但是一直没有实战过,做多了管理系统,发现这个事情真的没有过多的重视。最近......
  • springboot
    SpringBoot的启动主要是通过实例化SpringApplication来启动的,启动过程主要做了如下几件事情:  配置系统属性、获取监听器,发布应用开始启动事件、初始化参数、配置环......
  • SpringBoot - @RequestMapping 注解
    @Target({ElementType.TYPE,ElementType.METHOD})//只能在方法上使用@Retention(RetentionPolicy.RUNTIME)@Documented@Mappingpublic@interfaceRequestMapping{......
  • SpringBoot - 定时任务 @EnableScheduling,@Scheduled
    1.在启动类上添加@EnableScheduling注解,开启对定时任务的支持//开启对定时任务的支持@EnableScheduling@SpringBootApplicationpublicclassLearn20221218Applicatio......
  • VC6 编译报错 spawning link.exe
    报错背景我之前把D盘的VC6拷贝到E盘,后面点击“Compile”或者“Build”后被出现的“Compiling...,Errorspawningcl.exe”解决VC6比较古老了,它可能只在第一次使用的......
  • SpringBoot参数校验
    原文:https://juejin.cn/post/6856541106626363399简单使用JavaAPI规范(JSR303)定义了Bean校验的标准validation-api,但没有提供实现。hibernatevalidation是对这个规范的......
  • SpringBoot - 异步任务 @EnableAsync,@Async
    1.在启动类上添加@EnabnleAsync注解开启对异步任务的支持//开启对异步任务的支持@EnableAsync@SpringBootApplicationpublicclassLearn20221218Application{p......
  • ICMP-ping报错类型
        ICMP数据包的包头,两个重要字段Type和Code,如图所示  ICMP消息类型和编码类型 回显请求包,正常为80回显回复包,正常为00其余均为报错类型。超时:对方主......