Skip to content

mattfeltonma/demo-microsoft-foundry-authentication-code

Repository files navigation

Microsoft Foundry Authentication Code Samples

Overview

This repository contains code samples of different methods to authenticate to the Microsoft Foundry (and Azure OpenAI Service and Azure AI Service) using the Python openai library with both the legacy API and the Azure OpenAI v1 API, Python Azure AI Inference library, Python langchain-openai library, and Python requests library. Each example uses the ChatCompletions operation.

The samples assume the use of the python-dotenv library for storing sensitive variables.

The following authentication examples are provided:

  1. Managed Identity with Azure AI Inference SDK
  2. Service Principal with Azure AI Inference SDK
  3. API Key with LangChain
  4. Service Principal with LangChain
  5. API Key with OpenAI SDK with legacy API
  6. Managed Identity with OpenAI SDK with legacy API
  7. Service Principal with OpenAI SDK with legacy API using Client Credentials Flow)
  8. Service Principal with OpenAI SDK with legacy API using OBO Flow)
  9. API Key with OpenAI SDK with v1 API
  10. Managed Identity with OpenAI SDK with v1 API
  11. Service Principal with OpenAI SDK with v1 API using Client Credentials Flow)
  12. Service Principal with OpenAI SDK with v1 API using OBO Flow)
  13. API Key with REST API
  14. Service Principal with REST API

In each example you will find a requirements.txt file with the required libraries and a sample environmental variables file that can be used with the python-dotenv library. You will need to rename it from .env-sample to .env.

When using the on-behalf-of flow, you will need to property configure the application registration to support public client flows.

About

Python code samples for authenticating to Microsoft Foundry using different APIs.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages