microsoft / azure-spring-boot

Spring Boot Starters for Azure services
MIT License
374 stars 460 forks source link

User Assigned Identity fails with spring-cloud-azure-appconfiguration-config-web 4.8.0 #963

Closed ajpogue closed 2 months ago

ajpogue commented 1 year ago

I’ve been trying to get my Spring Boot service running in Azure App Service to use Azure App Configuration service to get configuration parameters. The app service uses a User Assigned Identity. Through a lot of trial and error, I have gotten it to work, but it only works with an old version of the app config package. Also noticed that in the docker logs the MSI container is not starting as expected:

If I use the following dependency in my project, it works:

dependency
groupId com.azure.spring/groupId
artifactId azure-spring-cloud-appconfiguration-config-web
/artifactId
version 2.11.0 /version
/dependency

But it seems that the above version is deprecated in favor of this dependency for Spring Boot (2.x):

dependency
groupId com.azure.spring
/groupId
artifactId  spring-cloud-azure-appconfiguration-config-web /artifactId
version 4.8.0 /version 
/dependency 

I have also tried updating the app to Spring Boot (3.x) with no luck.

If I update the package, the deployment fails on startup with
2023-06-19T15:37:12.539956477Z: [INFO]  2023-06-19 15:37:12.536 DEBUG 296 --- [           main] c.a.identity.ManagedIdentityCredential   : Azure Identity => Found the following environment variables: MSI_ENDPOINT, MSI_SECRET, AZURE_TENANT_ID
2023-06-19T15:37:20.230369505Z: [INFO]  2023-06-19 15:37:20.229 ERROR 296 --- [onPool-worker-1] c.a.identity.ManagedIdentityCredential   : Azure Identity => ERROR in getToken() call for scopes [https://XXX.azconfig.io/.default]: Managed Identity authentication is not available.
2023-06-19T15:37:20.239206040Z: [INFO]  2023-06-19 15:37:20.238 ERROR 296 --- [onPool-worker-1] c.a.c.implementation.AccessTokenCache    : {"az.sdk.message":"Failed to acquire a new access token.","exception":"Managed Identity authentication is not available."}

(Note that we are using Spring Boot 2.x because Azure Spring Data Cosmos does not support Spring Boot 3.x at this time (per https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/spring/azure-spring-data-cosmos#spring-boot-version-support). According to this other Spring Version mapping, I should be able to use Spring Cloud Azure version 4.x.x with Spring Boot 2.7.x: https://github.com/Azure/azure-sdk-for-java/wiki/Spring-Versions-Mapping#which-version-of-spring-cloud-azure-should-i-use

According to this site, https://learn.microsoft.com/en-us/azure/azure-app-configuration/howto-convert-to-the-new-spring-boot?tabs=spring-boot-2 I should be able to run with the 4.8.0 version of Spring Cloud Azure. Can you advise?

I also opened a support case 2306190040007997, but have heard the sdk is primarily supported through github.

pom.xml.txt

saragluna commented 1 year ago

What does the application.proeprties look like?

mrm9084 commented 1 year ago

@ajpogue how are you providing the User Assigned Identity?

Netyyyy commented 2 months ago

Close the issue for long term inactivity