spring-ai icon indicating copy to clipboard operation
spring-ai copied to clipboard

Microsoft Entra authentication

Open williamspindox opened this issue 1 year ago • 5 comments
trafficstars

Please add Microsoft Entra authentication for Azure: https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#authentication

williamspindox avatar Jan 23 '24 14:01 williamspindox

Thanks, we will look into this.

markpollack avatar Jan 23 '24 18:01 markpollack

I'm trying something like this on org.springframework.ai.autoconfigure.azure.openai.AzureOpenAiAutoConfiguration:

AzureProfile azureProfile = new AzureProfile(AzureEnvironment.AZURE); TokenCredential tokenCredential = new ClientSecretCredentialBuilder() .clientId("xxxxxxxxxxxxxxxxx") .clientSecret("xxxxxxxxxxxxxxxxx") .tenantId("xxxxxxxxxxxxxxxxx") .authorityHost(azureProfile.getEnvironment().getActiveDirectoryEndpoint()) .build(); return new OpenAIClientBuilder().endpoint(connectionProperties.getEndpoint()) .credential(tokenCredential) .buildClient();

It works, I get:

Azure Identity => getToken() result for scopes [https://cognitiveservices.azure.com/.default]: SUCCESS {"az.sdk.message":"Acquired a new access token."}

williamspindox avatar Jan 24 '24 16:01 williamspindox

When will it be available on your release? Thank you

williamspindox avatar Jan 30 '24 18:01 williamspindox

also see https://github.com/spring-projects/spring-ai/issues/309

markpollack avatar Feb 29 '24 17:02 markpollack

https://github.com/spring-projects/spring-ai/pull/448

williamspindox avatar Mar 15 '24 06:03 williamspindox

I will ask someone from microsoft to review this, I am not able to easily evaluate what is going on here. Sorry it is taking a while.

markpollack avatar May 24 '24 15:05 markpollack

No problem. I've already tested my PR with the Entra authentication on Azure and it works great, but welcome a check by someone from Microsoft. Regards.

williamspindox avatar May 24 '24 15:05 williamspindox