Claude Code with Microsoft Foundry
Since all the frontier models from Anthropic are now available on Microsoft Foundry, you can also use Claude Code without a plan at Anthropic itself. In this guide i show you how to connect Claude Code with your Microsoft Foundry models.
Prerequisites Ensure you have:
- An Azure subscription with access to Microsoft Foundry
- RBAC permissions to create Foundry resources and deployments
- Claude Code installed (see setup instructions)
1. Provision a Foundry Resource
- Go to the Microsoft Foundry portal: https://ai.azure.com/
- Create a new Foundry resource and note its name.
- Create deployments for the models you intend to use (e.g., Claude Opus, Sonnet, Haiku).
Make sure to use the default name for the deployment like "claude-haiku-4-5" because this is the default how claude code will access the models. No matter whether you are planning to work with Opus or with Sonnet make sure to also deploy Haiku 4.5, since it is used by claude code for smaller tasks automatically.
2. Configure Authentication
- Open your Foundry resource.
- Navigate to Endpoints and keys.
- Copy an API key.
- Configure your environment:
export ANTHROPIC_FOUNDRY_API_KEY="your-api-key"
3. Configure Claude Code Set environment variables to enable Foundry integration and model routing:
# Enable Foundry
export CLAUDE_CODE_USE_FOUNDRY=1 # Resource name or base URL
export CLAUDE_CODE_USE_FOUNDRY=1 # Resource name or base URL
export ANTHROPIC_FOUNDRY_RESOURCE="{resource}" # or: #
#export ANTHROPIC_FOUNDRY_BASE_URL="https://{resource}.services.ai.azure.com"
# Map models to your Foundry deployment names (You can skip this part when you went with the default deployment names)
export ANTHROPIC_DEFAULT_SONNET_MODEL="claude-sonnet-4-5"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="claude-haiku-4-5"
export ANTHROPIC_DEFAULT_OPUS_MODEL="claude-opus-4-5"
4. Happy Coding
Now you have successfully completed the setup of claude code with your own model deployments and you are ready to explore the power of this nice little tool. But before you go and make the GPUs burn make sure to check the pricing of the models you are going to use, since they are no steal. And also double check if those model consumptions is included in your free credits, since most of the free credits do not cover Foundry Models that are not provided directly by Azure.
