LangGraph-Azure Deployment Template
AgentProduction-ready starter template for deploying LangGraph agents on Azure AI Foundry with auto-scaling, Cosmos DB checkpoints, and CI/CD.
LangGraph-Azure Deployment Template
Overview
Starter template for deploying LangGraph agent systems on Azure AI Foundry using the langgraph-azure SDK. This template provides a production-ready project structure with auto-scaling workers, Cosmos DB checkpoint persistence, Azure OpenAI integration, and cost monitoring — all configured with minimal boilerplate.
Quick Start
# 1. Clone and install
git clone https://github.com/microsoft/langgraph-azure-template
cd langgraph-azure-template
pip install -r requirements.txt
# 2. Authenticate with Azure
az login
az account set --subscription <your-subscription-id>
# 3. Set environment variables
export AZURE_SUBSCRIPTION_ID="<your-sub>"
export AZURE_RESOURCE_GROUP="agents-rg"
export AZURE_OPENAI_DEPLOYMENT="gpt-4o"
export AZURE_COSMOS_ACCOUNT="agents-cosmos"
# 4. Deploy
python deploy.py
Project Structure
langgraph-azure-template/
├── agents/
│ ├── __init__.py
│ ├── research_agent.py # LangGraph node implementations
│ ├── analysis_agent.py
│ └── graph.py # Graph definition and compilation
├── config/
│ └── azure_config.py # Azure deployment configuration
├── tests/
│ ├── test_graph.py
│ └── test_integration.py
├── deploy.py # Azure deployment script
├── main.py # Local development server
├── requirements.txt
└── azure-pipelines.yml # CI/CD pipeline
Template Files
requirements.txt
langgraph>=2.1.0
langgraph-azure>=0.1.0
openai>=1.40.0
azure-identity>=1.15.0
azure-cosmos>=4.6.0
pytest>=8.0.0
config/azure_config.py
from langgraph_azure import AzureGraphDeployment
def get_deployment_config() -> AzureGraphDeployment:
return AzureGraphDeployment(
resource_group="agents-rg",
location="eastus",
openai_deployment="gpt-4o",
cosmos_db_account="agents-cosmos",
cosmos_db_database="langgraph",
auto_scale={
"min_replicas": 2,
"max_replicas": 20,
"scale_metric": "concurrent_graph_runs",
"cooldown_period": 60
},
monitoring={
"log_level": "info",
"sampling_rate": 0.1
}
)
agents/graph.py
from langgraph import StateGraph, START, END
from typing import TypedDict
from agents.research_agent import research_node
from agents.analysis_agent import analysis_node
class AgentState(TypedDict):
input: str
research: list
analysis: str
output: str
def build_graph() -> StateGraph:
graph = StateGraph(AgentState)
graph.add_node("research", research_node)
graph.add_node("analysis", analysis_node)
graph.add_edge(START, "research")
graph.add_edge("research", "analysis")
graph.add_edge("analysis", END)
return graph
app = build_graph().compile()
deploy.py
from config.azure_config import get_deployment_config
from agents.graph import app
def deploy():
config = get_deployment_config()
deployment = config.deploy(app, name="production-agent-v1")
print(f"Deployed to: {deployment.endpoint}")
print(f"Region: {deployment.region}")
if __name__ == "__main__":
deploy()
main.py (Local Development)
from agents.graph import app
if __name__ == "__main__":
print("LangGraph Agent — Local Development Mode")
print("Type 'quit' to exit\n")
while True:
user_input = input("> ")
if user_input.lower() == "quit":
break
result = app.invoke({"input": user_input})
print(f"\n{result['output']}\n")
azure-pipelines.yml
trigger:
branches:
include: [main]
pool:
vmImage: 'ubuntu-latest'
stages:
- stage: Test
jobs:
- job: UnitTest
steps:
- task: UsePython@0
inputs:
versionSpec: '3.12'
- script: pip install -r requirements.txt
- script: pytest tests/ --junitxml=test-results.xml
- stage: Deploy
dependsOn: Test
jobs:
- deployment: AzureDeploy
environment: production
strategy:
runOnce:
deploy:
steps:
- task: AzureCLI@2
inputs:
azureSubscription: '$(AzureSub)'
scriptLocation: inline
inlineScript: |
python deploy.py
Local Testing
# tests/test_graph.py
from agents.graph import app
def test_basic_flow():
result = app.invoke({"input": "What is LangGraph?"})
assert "output" in result
assert len(result["output"]) > 0
def test_state_persistence():
# Simulate interruption and resume
checkpoint = app.get_checkpointer().get("thread-1")
assert checkpoint is not None
pytest tests/ -v
Pros
- Zero-config Azure deployment from standard LangGraph code
- Enterprise-grade auto-scaling and monitoring out of the box
- SOC 2 compliant with RBAC and VNet support
- CI/CD pipeline included for automated deployments
- Local development mode identical to production behavior
Cons
- Azure-only — no support for AWS, GCP, or on-premises
- Requires Azure subscription and OpenAI resource provisioning
- Cosmos DB checkpoint costs can be significant for high-state graphs
- New SDK with limited community resources
When to Use
- You are deploying LangGraph agents to Azure at production scale
- Your organization requires enterprise compliance and RBAC
- You need auto-scaling for variable workloads
- You want a starting point for a LangGraph on Azure project
