Giving Developers Claude Code with Azure API Management and Claude Models in Microsoft Foundry
Summary
This article details a production-ready architecture for providing developers secure access to Anthropic's "Claude Code" models hosted in Microsoft Foundry, billed through an Azure subscription. The pattern leverages Azure API Management (APIM) as an LLM gateway, authenticating individual developers via Entra ID. APIM enforces per-user rate limits and token quotas using GenAI policies, and emits usage metrics for cost tracking. Foundry can reside in a separate Azure subscription, with APIM authenticating to it using either a Foundry "api-key" (suitable for cross-tenant scenarios) or a managed identity (preferred for production, eliminating shared secrets). Developers only handle short-lived Entra tokens, ensuring Foundry keys never leave APIM. The guide includes PowerShell steps for Windows developers and covers deployment of Claude Sonnet 4.6, Haiku 4.5, and Opus 4.6 in regions like East US 2 or Sweden Central.
Key takeaway
For AI Architects or MLOps Engineers tasked with securely scaling LLM access, this pattern provides a robust solution. You should implement Azure API Management as a "Claude Code" gateway to centralize authentication via Entra ID, enforce per-developer token quotas, and gain granular cost visibility. This approach eliminates key sprawl and enables seamless upgrades to managed identity and private networking without disrupting developer workflows.
Key insights
Centralize "Claude Code" access via Azure APIM to manage authentication, usage, and cost for developers.
Principles
- Decouple developer-facing and backend authentication.
- Meter LLM usage by tokens, not just requests.
- Pin model versions to prevent breaking changes.
Method
Deploy Claude models in Microsoft Foundry, configure Entra ID app registration, provision APIM API with GenAI policies, and set up "Claude Code" clients with an "api-key" helper.
In practice
- Use "llm-token-limit" and "rate-limit-by-key" for granular control.
- Implement Key Vault-backed named values for "api-key" rotation.
- Switch to managed identity for APIM-to-Foundry authentication in production.
Topics
- Azure API Management
- Microsoft Foundry
- Claude Code
- Entra ID
- LLM Gateway
- Token Management
- Cost Tracking
Best for: AI Engineer, MLOps Engineer, AI Architect
Related on AIssential
Editorial summary, takeaway, and curation by AIssential. Original article published by Microsoft Foundry Blog articles.