Skip to main content
This page covers Azure AI package selection, Foundry setup, memory, vector stores, backends, hosted agents, and durable execution for Microsoft Azure. For a card-based index of Microsoft integrations, see Microsoft integrations. Integration packages for Azure AI, Dynamic Sessions, SQL Server are maintained in the langchain-azure repository. The same repository maintains the Azure Durable Task Scheduler extension. A Foundry resource includes Azure OpenAI capabilities and adds a broader model catalog, agent service, and evaluation capabilities. If you use an Azure OpenAI resource, upgrade it to a Foundry resource to keep your existing API endpoint, state, and security configurations while gaining access to Foundry capabilities. For agent hosting, use Microsoft Foundry hosted agents to deploy custom LangGraph code on a managed agent platform with built-in runtime, sessions, scaling, identity, and protocol endpoints.

Choose a package

langchain-azure-ai and langchain-openai are complementary rather than alternatives. langchain-azure-ai depends on langchain-openai, and its chat and embeddings classes subclass ChatOpenAI and OpenAIEmbeddings, so installing the Azure package does not remove the OpenAI package from your dependency chain. Use the following table to pick a starting point: Moving an existing langchain-openai application to langchain-azure-ai is not a drop-in import change:
  • Configuration differs. azure_endpoint, azure_deployment, api_version, and token-provider arguments become project_endpoint or endpoint, model, and credential.
  • Default behavior differs. AzureAIOpenAIApiChatModel defaults to the Responses API when it resolves a project endpoint. Set use_responses_api=False to keep Chat Completions behavior.
  • No completion-LLM equivalent to AzureOpenAI exists in langchain-azure-ai.
  • AzureChatOpenAI carries Azure-specific response metadata and content-filter handling that the Foundry chat model does not reproduce.
  • Both packages follow the official OpenAI schemas, so non-standard fields returned by compatible providers such as DeepSeek or Mistral may not be preserved.

Chat models

Microsoft offers three main options for accessing chat models through Azure:
  1. Microsoft Foundry (recommended for project-centric applications): Use AzureAIOpenAIApiChatModel from langchain-azure-ai with a Foundry project endpoint and Azure credentials. This package also integrates with Foundry agents, hosting, tools, Content Safety, retrieval, and observability.
  2. Azure OpenAI: Use ChatOpenAI from langchain-openai for direct v1 API calls or code that switches between OpenAI and Azure. Use AzureChatOpenAI for traditional Azure OpenAI API versions and existing applications.
  3. Azure ML: Allows deployment and management of custom or fine-tuned open-source models with Azure Machine Learning.
Start with langchain-azure-ai to access the models available in Azure AI Foundry.

Azure AI chat completions

Access models like Azure OpenAI, DeepSeek R1, Cohere, Phi and Mistral using the AzureAIOpenAIApiChatModel class.
Configure your endpoint. You can use a project endpoint with DefaultAzureCredential, or set an API key directly.

LLMs

Microsoft offers two main options for accessing LLMs through Azure:
  1. Azure OpenAI (recommended): Use Azure OpenAI text-completion deployments with AzureOpenAI from langchain-openai.
  2. Azure ML: Use custom or open-source models hosted on Azure Machine Learning online endpoints.

Embedding models

Choose an embeddings integration based on how your application connects to Azure:
  1. Microsoft Foundry (recommended for project-centric applications): Use AzureAIOpenAIApiEmbeddingsModel from langchain-azure-ai with Foundry project configuration and Azure credentials.
  2. Azure OpenAI: Use AzureOpenAIEmbeddings from langchain-openai for direct or traditional Azure OpenAI endpoints, existing applications, or a smaller dependency surface.

Microsoft Foundry embeddings

Configure your endpoint. You can use a project endpoint with DefaultAzureCredential, or set an API key directly.
Foundry project configuration currently derives a direct /openai/v1 endpoint because embeddings are not yet served through the project endpoint itself.

Backends

Azure Blob Storage Backend

Azure Blob Storage is Microsoft’s object storage solution for the cloud. AzureBlobBackend implements the Deep Agents BackendProtocol, so a deep agent can persist its entire workspace (files, memories, and artifacts) in a blob container.
The AzureBlobBackend is part of the langchain-azure-storage package, which is currently in Public Preview.
Install with the deepagents extra (requires Python 3.11+):
Quick start:
The backend defaults to DefaultAzureCredential and accepts a credential override. For more information, see Backend integrations. See the package repository for full usage details and security guidance.

Memory

Azure cosmos DB chat message history

Azure Cosmos DB provides chat message history storage for conversational AI applications, enabling you to persist and retrieve conversation history with low latency and high availability.
Configure your Azure Cosmos DB connection (sync or async, with access key or Microsoft Entra ID):
For async usage, import AsyncCosmosDBChatMessageHistory from the same package.

Azure cosmos DB semantic cache

AzureCosmosDBNoSqlSemanticCache caches LLM responses in Azure Cosmos DB for NoSQL using vector similarity, returning cached results when a semantically similar prompt is seen again.
For async usage, import AsyncAzureCosmosDBNoSqlSemanticCache.

Vector stores

Azure CosmosDB NoSQL is a fully managed, globally distributed, serverless document database for modern applications. It stores data in flexible JSON documents and uses a SQL-like query language. This provides high performance, low latency, and automatic, elastic scalability. It also features integrated vector search capabilities for AI workloads like generative AI and RAG. This allows you to store, index, and query vector embeddings alongside your operational data in the same database. You can combine vector similarity search with traditional keyword-based search for relevant results and choose from various indexing methods for optimal performance. This unified approach simplifies application architecture and ensures data consistency.
We need to install the langchain-azure-cosmosdb and azure-cosmos packages to use this vector store.
See a usage example.
Azure CosmosDB Mongo vCore architecture makes it easy to create a database with full native MongoDB support. You can apply your MongoDB experience and continue to use your favorite MongoDB drivers, SDKs, and tools by pointing your application to the API for MongoDB (vCore) cluster’s connection string.
Install pymongo and langchain-azure-cosmosdb to use this vector store.
See a usage example.

Azure SQL Database

Azure SQL Database is a robust service that combines scalability, security, and high availability, providing all the benefits of a modern database solution. It also provides a dedicated Vector data type & built-in functions that simplifies the storage and querying of vector embeddings directly within a relational database. This eliminates the need for separate vector databases and related integrations, increasing the security of your solutions while reducing the overall complexity.
By leveraging your current SQL Server databases for vector search, you can enhance data capabilities while minimizing expenses and avoiding the challenges of transitioning to new systems.

Installation and setup

See detail configuration instructions. Install the langchain-sqlserver package:

Deploy Azure SQL DB on Microsoft Azure

Sign Up for free to get started today. See a usage example.
Azure AI Search is a cloud search service for vector, keyword, and hybrid retrieval.
The AzureSearch vector store and the AzureAISearchRetriever retriever ship in langchain-azure-ai.
See the vector store guide and the retriever guide.

Runtime

Microsoft Foundry hosted agents

Microsoft Foundry hosted agents run custom LangGraph code in a managed runtime. Use the langchain_azure_ai.agents.hosting package to expose a compiled LangGraph graph while Foundry manages the runtime, sessions, scaling, identity, and protocol endpoints.
LangGraph hosting support requires langchain-azure-ai[hosting]>=1.2.8.
Before you begin, you need an Azure subscription, a Foundry project, a deployed chat model, Python 3.10 or later, and Azure CLI authentication. Deploying the agent also requires the Foundry Project Manager role on the project. Choose a hosting protocol based on how clients interact with the agent:
For hosted graphs using BaseChatOpenAI-based models with the Responses API, use output_version="responses/v1". You can omit this setting in langchain-openai 1.0.0 or later, unless overridden by LC_OUTPUT_VERSION. This guidance applies to both Responses and Invocations hosting protocols.
See the complete run samples for the Responses protocol and Invocations protocol.

Use the configuration-driven runner

If your agent already runs with the LangGraph CLI, use langchain_azure_ai.agents.hosting.run tool from the same project directory. The runner uses the existing langgraph.json configuration to load the compiled graph, so no code change is needed. Set the Foundry project endpoint and model deployment name, then select the protocol when you start the host:
For deployment, set codeConfiguration.entryPoint on the agent service in azure.yaml to the same runner and protocol. Keep the existing project path, runtime, and dependency resolution settings:

Use the SDK host classes

Use the SDK host classes when you need to customize server construction, control the server lifecycle directly, or implement advanced hosting behavior such as custom routes or handlers:
To deploy either approach, use azd ai agent init to initialize a hosted-agent project, azd ai agent run to test it locally, and azd deploy to deploy it. Run azd provision first only when you need to create the Foundry project or other Azure resources. You can also deploy with the Foundry Toolkit Visual Studio Code extension. The Microsoft Learn guide includes complete examples for both protocols, conversation state, human-in-the-loop flows, testing, deployment, and troubleshooting.

Durable LangGraph execution with Azure Durable Task Scheduler

langchain_azure_compute.graph wraps a compiled LangGraph StateGraph, a LangChain create_agent workflow, or a Deep Agents create_deep_agent graph in a deterministic Azure Durable Task Scheduler (DTS) orchestration with attach_durability(graph, name="..."). Model calls, tools, and graph steps run in activities rather than in the replaying orchestrator. create_deep_agent also requires the deepagents package.
The durable execution integration is in public preview. Its API may change. Requires langchain-azure-compute 0.2.0 or later.
The adapter separates the execution control plane from the graph state plane. Keep checkpoints in a LangGraph saver such as SqliteSaver, PostgresSaver, or CosmosDBSaver. Make persistent checkpoint storage accessible to every worker. With a persistent saver, step transitions pass checkpoint references, while durable tool/node inputs and outputs and final results still pass through DTS. Without a checkpointer, the adapter attaches an InMemorySaver and carries checkpoint bundles in DTS payloads.
  • Activity isolation: Use @durable_tool(retries=3) to configure a tool’s independent retry policy, and @durable_node to isolate a graph node as an activity.
  • Worker crash failover: Another worker registered with the same graph and task hub can resume execution from persisted progress.
  • Human-in-the-loop waits: LangGraph interrupt() pauses execution using DTS external events without holding worker threads or consuming compute for the wait. Read the interrupt with run.wait_pending() and continue it with run.resume(pending, value).
  • Azure Functions HTTP routes: LangGraphFunctionApp exposes start, status, and respond routes on Azure Functions Python v2. HTTP control routes do not replace a graph worker. Run dedicated DurableTaskSchedulerWorker replicas against the same scheduler and hub; embedded workers are not supported on Consumption or Flex plans. Function apps also require verified caller identity and per-instance ownership checks. See the Azure Functions human-in-the-loop sample.
Install the durable execution extra alongside the Foundry model integration:
Set AZURE_AI_PROJECT_ENDPOINT and AZURE_AI_MODEL_DEPLOYMENT_NAME for your deployed model, and authenticate with Microsoft Entra ID (az login for local development). Your credential requires the Foundry User role on the Foundry project. For Azure DTS, set DURABLE_TASK_SCHEDULER_CONNECTION_STRING. Use managed identity in production and grant the identity the Durable Task Data Contributor role on the intended scheduler/task hub. For a running local DTS emulator, set DTS_ENDPOINT=127.0.0.1:8080 instead. sdk_options() resolves these connection and authentication settings. This example runs a read-only tool as an isolated activity with up to three attempts:
Activities execute at least once, not exactly once. A crash after an external side effect but before its completion acknowledgement can repeat that effect. Use a durable idempotency key at the external mutation boundary, such as runtime.config["metadata"]["durable_call_id"]. DTS history contains activity inputs and outputs, and may contain checkpoints and final graph state; review its retention and purge settings independently of checkpoint storage.
For checkpoint configuration, payload limits, human approvals, and production hosting, see the durable execution package guide.

Samples and tutorials