azure-sdk-for-net
azure-sdk-for-net copied to clipboard
[QUERY] Integrating Azure AD Token Authorization in .NET by passing authorization token
Library name and version
Azure.AI.OpenAI --version 2.0.0-beta.2
Query/Question
Hello,
I am currently using Azure AD token to authorize the client in Python and it's working fine with the Python library. Here is the relevant code snippet from the Python library:
https://github.com/openai/openai-python/blob/6316b7c0f182877e578a3dbed2fd129b63538af5/src/openai/lib/azure.py#L291
However, I am facing difficulties when trying to implement the same in .NET. Currently, my only option is to create my own HTTP client and make REST calls and passing request header
Authorization : Bearer ****
It would be great if you could provide some guidance or point me to the relevant documentation or examples. Any help would be greatly appreciated.
Thank you.
Environment
Windows 11 dotnet 6
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @jpalvarezl @ralph-msft @trrwilson.
@shouryashashank : The Azure SDK clients make use of the Azure.Identity library to integrate with Entra ID and other token-based sources. Each client, including the AzureOpenAIClient, have constructor overloads that accept a TokenCredential instance.
For example:
AzureOpenAIClient azureClient = new(
new Uri("https://your-azure-openai-resource.com"),
new DefaultAzureCredential());
More discussion and links to further examples can be found in the Azure OpenAI README
Hi @shouryashashank. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text "/unresolve" to remove the "issue-addressed" label and continue the conversation.
Hi @shouryashashank, since you haven’t asked that we /unresolve the issue, we’ll close this out. If you believe further discussion is needed, please add a comment /unresolve to reopen the issue.