Overview
Azure OpenAI Service provides the same powerful OpenAI models (GPT-4o, GPT-4o-mini) through Microsoft’s Azure cloud platform, offering:- Enterprise Security: Azure’s compliance and security features
- Private Network: Deploy within your Azure virtual network
- SLA Guarantees: 99.9% uptime commitment
- Data Residency: Keep data within specific regions
- Cost Management: Azure billing and cost controls
Prerequisites
Azure Account
Create an Azure account at portal.azure.com
Create Azure OpenAI Resource
- Go to Azure Portal
- Search for “Azure OpenAI”
- Click “Create”
- Select subscription, resource group, and region
- Wait for deployment to complete
Deploy a Model
- Go to your Azure OpenAI resource
- Navigate to “Model deployments”
- Click “Create new deployment”
- Select model (e.g.,
gpt-4o-mini) - Give it a deployment name (e.g.,
gpt-4o-mini-deployment)
Get Credentials
From Azure OpenAI resource overview:
- Endpoint:
https://YOUR-RESOURCE-NAME.openai.azure.com/ - API Key: Found in “Keys and Endpoint” section
- API Version: e.g.,
2024-02-15-preview
Basic Configuration
Environment Variables
Create a.env file:
.env
Always use environment variables for credentials - never hardcode them in your source code.
Available Models
- Recommended
- All Models
Configuration Options
Required Parameters
Optional Parameters
Authentication Methods
- API Key (Recommended)
- Azure Active Directory
- Managed Identity
Use API key authentication (simplest method):
Complete Examples
Troubleshooting
Invalid Deployment Name
Invalid Deployment Name
Error:
DeploymentNotFound: The API deployment for this resource does not existSolution:- Check deployment name in Azure Portal
- Ensure it matches exactly (case-sensitive)
- Verify deployment is in “Succeeded” state
Wrong API Version
Wrong API Version
Error: Check Azure OpenAI API versions for latest.
InvalidApiVersion: The API version is not supportedSolution: Use a valid API version:Rate Limit Exceeded
Rate Limit Exceeded
Error:
RateLimitError: Requests to the API are being rate limitedSolution:- Increase quota in Azure Portal
- Add retry logic with backoff
- Distribute load across multiple deployments
Authentication Failed
Authentication Failed
Error:
AuthenticationError: Access deniedSolution:- Verify API key is correct
- Check key hasn’t expired
- Ensure resource is not paused/deleted
- Verify network access (if using Private Endpoint)
Best Practices
Use Key Vault
Store credentials in Azure Key Vault:
Multi-Region Deployment
Deploy to multiple regions for high availability:
- Primary: East US
- Failover: West Europe
- Backup: Southeast Asia
Monitor Usage
Use Azure Monitor to track:
- Token usage
- Request latency
- Error rates
- Cost trends
Cost Management
Implement cost controls:
- Set budget alerts
- Use gpt-4o-mini for most tasks
- Cache common responses
- Monitor token usage
Regional Considerations
Model availability varies by Azure region. Popular regions for Azure OpenAI:
- East US: Best availability, all models
- West Europe: GDPR compliance
- UK South: UK data residency
- Australia East: APAC customers
- Canada Central: Canadian data residency
Next Steps
Advanced Configuration
Learn about proxy rotation and browser settings
OpenAI
Compare with standard OpenAI API
