問題描述
Spring Cloud Azure 4.0 調用 Key Vault 的代碼中宠默,沒有找到設置 authority-host 的配置項麸恍,導致認證出現(xiàn)錯誤
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. 因為在遷移前搀矫,登錄的為中國區(qū)Azure AAD抹沪,而修改后刻肄,因為沒有找到指定 authority-host 為 https://login.partner.microsoftonline.cn 的配置項,所以默認的認證host變?yōu)?Global Azure采够,所以提示Tenant Id 無效肄方。
解決方式
Azure Spring 4.0中對于China Azure做了很多配置項,可以在全局指定蹬癌,也可以在服務中指定权她。
如果在 spring.cloud.azure.keyvault.secret.property-source[n]….. 中,可以嘗試以下配置:
- spring.cloud.azure.keyvault.profile.cloud-type: azure_china
- spring.cloud.azure.keyvault.secret.profile.environment.active-directory-endpoint: https://login.partner.microsoftonline.cn
參考資料
自 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
當在復雜的環(huán)境中面臨問題逝薪,格物之道需:濁而靜之徐清隅要,安以動之徐生。 云中董济,恰是如此!
標簽: Azure Key Vault, Azure Spring Cloud, Spring Cloud Azure 4.0, AADSTS90002: Tenant not found.