langchain-azure-ai package as the entry point for building LangChain and
LangGraph applications with Microsoft Foundry capabilities. This article gives
you a high-level map of the package so you can start quickly, then move to the
right deep-dive documentation for each capability.
Prerequisites
- An Azure subscription. Create one for free.
- A Foundry project.
- The Foundry User role on the Foundry project (least-privilege role for
The Foundry RBAC roles were recently renamed. Foundry User, Foundry Owner, Foundry Account Owner, and Foundry Project Manager were previously named Azure AI User, Azure AI Owner, Azure AI Account Owner, and Azure AI Project Manager. You might still see the previous names in some places while the rename rolls out. The role IDs and core permissions are unchanged by the rename. development). If you also create or manage resources, use Contributor or Owner as needed. For details, see Role-based access control for Microsoft Foundry.
- Python 3.10 or later.
- Azure CLI signed in (
az login) soDefaultAzureCredentialcan authenticate.
Install the package
Install the base package:- Use
[tools]if your app uses tools from the namespacelangchain_azure_ai.tools.*, like Document Intelligence. - Use
[opentelemetry]if you want tracing integration via OpenTelemetry.
Choose integration building blocks
Use this map to pick the right namespace for your solution:
See the section Learn each capability in detail for specific walkthroughs.
Connect with project endpoints and credentials
Manylangchain-azure-ai classes support connecting through a Foundry project
endpoint. Set AZURE_AI_PROJECT_ENDPOINT once, then reuse it across supported
classes.
project_endpoint, authentication uses Microsoft Entra ID and
Azure RBAC on the project.
API keys are for direct service endpoints, such as /openai/v1.
Example: Use Foundry Models
Once the environment variables are configured, you can use a model by:AzureAIOpenAIApiChatModel as a representative pattern:
AzureAIDocumentIntelligenceTool can use the project endpoint and
DefaultAzureCredential without extra configuration when
AZURE_AI_PROJECT_ENDPOINT is set:
How DefaultAzureCredential works
DefaultAzureCredential tries several Microsoft Entra ID credential sources in
order and uses the first one that works. Common sources are environment
variables, managed identity, developer tools, and Azure CLI.
Use DefaultAzureCredential as the default for local development and deployed
workloads. If you need stricter control, replace it with a specific credential
such as AzureCliCredential for local-only development or
ManagedIdentityCredential for production workloads in Azure.
The same project-endpoint pattern is also used by other classes.
Learn each capability in detail
Start with these guides in this documentation set:- Use Foundry Models with LangChain and LangGraph
- Use Foundry Content Safety middleware
- Use Foundry Agent Service with LangGraph
- Use Foundry Toolbox with LangChain
- Host LangGraph agents as Foundry hosted agents
- Use Foundry Memory with LangChain and LangGraph
- Use Foundry Observability to trace apps