GraphRAG seamlessly integrates with Azure OpenAI to provide enterprise-grade LLM capabilities. This guide walks you through setting up Azure OpenAI for use with GraphRAG.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/microsoft/graphrag/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
Before starting, ensure you have:- An active Azure subscription
- Access to Azure OpenAI Service
- Deployed models for chat completion and embeddings
- GraphRAG installed (
pip install graphrag)
Azure OpenAI setup
Deploy Azure OpenAI models
In the Azure Portal, deploy the required models:
- Navigate to your Azure OpenAI resource
- Go to “Model deployments”
- Deploy a chat model (e.g.,
gpt-4o,gpt-4-turbo) - Deploy an embedding model (e.g.,
text-embedding-3-small)
Gather connection information
Collect the following from your Azure OpenAI resource:
- Endpoint URL:
https://YOUR-RESOURCE-NAME.openai.azure.com/ - API Key: Found under “Keys and Endpoint”
- API Version: Use
2024-02-15-previewor later - Deployment names: The names you gave your models
Configuration
Environment variables
The recommended approach is to store sensitive information in environment variables.Rate limiting
Azure OpenAI has token-per-minute (TPM) and requests-per-minute (RPM) limits. Configure these in your settings:settings.yaml
Model configurations
Chat models
Different Azure OpenAI chat models have different capabilities and costs:- GPT-4o
- GPT-4 Turbo
- GPT-3.5 Turbo
Latest and most capable model:Best for: Complex reasoning, high-quality extractions
Embedding models
- text-embedding-3-small
- text-embedding-3-large
- text-embedding-ada-002
Balanced performance and cost:Dimensions: 1536
Multiple model configurations
You can use different models for different workflows:settings.yaml
Azure AI Search integration
For production deployments, use Azure AI Search as your vector store:settings.yaml
Get connection details
- URL:
https://YOUR-SERVICE-NAME.search.windows.net - API Key: Found in “Keys” section
Testing your configuration
Verify your Azure setup before running a full index:Cost optimization
Optimize costs when using Azure OpenAI:1. Use appropriate models
Development
Use GPT-3.5 Turbo for testing and development
Production
Use GPT-4o or GPT-4 Turbo for final production runs
2. Enable caching
settings.yaml
3. Optimize chunking
settings.yaml
4. Batch processing
settings.yaml
Authentication methods
API key authentication
The standard method shown above:.env
Azure AD / Entra ID authentication
For enhanced security, use Azure AD:settings.yaml
Troubleshooting
Common issues
401 Unauthorized error
401 Unauthorized error
404 Not Found error
404 Not Found error
Cause: Incorrect deployment name or endpointSolution:
- Verify
deployment_namematches your Azure deployment exactly - Check that
api_baseends with/or doesn’t, based on API version - Ensure the model is deployed in the same region as your endpoint
429 Rate limit exceeded
429 Rate limit exceeded
Cause: Exceeding Azure OpenAI quotaSolution:
- Reduce
requests_per_minuteandtokens_per_minutein config - Request quota increase in Azure Portal
- Implement retry logic with exponential backoff
Model not found error
Model not found error
Cause: Model not deployed or incorrect API versionSolution:
- Deploy the model in Azure Portal
- Use API version
2024-02-15-previewor later - Match
modelparameter to your deployment name
Validation checklist
- Azure OpenAI resource is created and active
- Chat model (e.g., gpt-4o) is deployed
- Embedding model (e.g., text-embedding-3-small) is deployed
- API key is copied to
.envfile -
api_baseURL is correct -
deployment_namematches Azure deployment exactly -
model_provideris set toazure - Rate limits match your Azure quota
- Dry run completes without errors
Example complete configuration
Here’s a complete working configuration for Azure:Next steps
Configuration reference
Explore all configuration options
CLI usage
Learn GraphRAG commands
Best practices
Optimize your implementation
Migration guide
Upgrade between versions