Documentation Index
Fetch the complete documentation index at: https://code.claude.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
Before configuring Claude Code with Microsoft Foundry, ensure you have:- An Azure subscription with access to Microsoft Foundry
- RBAC permissions to create Microsoft Foundry resources and deployments
- Azure CLI installed and configured (optional - only needed if you don’t have another mechanism for getting credentials)
If you are deploying Claude Code to multiple users, pin your model versions to prevent breakage when Anthropic releases new models.
Setup
1. Provision Microsoft Foundry resource
First, create a Claude resource in Azure:- Navigate to the Microsoft Foundry portal
- Create a new resource, noting your resource name
- Create deployments for the Claude models:
- Claude Opus
- Claude Sonnet
- Claude Haiku
2. Configure Azure credentials
Claude Code supports two authentication methods for Microsoft Foundry. Choose the method that best fits your security requirements. Option A: API key authentication- Navigate to your resource in the Microsoft Foundry portal
- Go to the Endpoints and keys section
- Copy API Key
- Set the environment variable:
ANTHROPIC_FOUNDRY_API_KEY is not set, Claude Code automatically uses the Azure SDK default credential chain.
This supports a variety of methods for authenticating local and remote workloads.
On local environments, you commonly may use the Azure CLI:
When using Microsoft Foundry, the
/login and /logout commands are disabled since authentication is handled through Azure credentials.3. Configure Claude Code
Set the following environment variables to enable Microsoft Foundry:4. Pin model versions
Set the model variables to match the deployment names you created in step 1. WithoutANTHROPIC_DEFAULT_OPUS_MODEL, the opus alias on Foundry resolves to Opus 4.6. Set it to the Opus 4.7 ID to use the latest model:
ANTHROPIC_DEFAULT_HAIKU_MODEL to a Haiku deployment that is available in your account, as shown above.
For current and legacy model IDs, see Models overview. See Model configuration for the full list of environment variables.
Prompt caching is enabled automatically. To request a 1-hour cache TTL instead of the 5-minute default, set the following variable; cache writes with a 1-hour TTL are billed at a higher rate:
5. Run Claude Code
With the environment variables set, start Claude Code from your project directory:CLAUDE_CODE_USE_FOUNDRY and the other Foundry variables from the environment and connects to your Azure resource on the first prompt. Unlike Bedrock and Vertex AI, Foundry has no interactive setup wizard, so the environment variables in steps 3 and 4 are the only configuration path.
Azure RBAC configuration
TheAzure AI User and Cognitive Services User default roles include all required permissions for invoking Claude models.
For more restrictive permissions, create a custom role with the following:
Troubleshooting
If you receive an error “Failed to get token from azureADTokenProvider: ChainedTokenCredential authentication failed”:- Configure Entra ID on the environment, or set
ANTHROPIC_FOUNDRY_API_KEY.