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 before rolling out.
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, noting the deployment name you give each; you’ll set these names as the model variables in step 4:
- Claude Opus
- Claude Sonnet
- Claude Haiku
2. Configure Azure credentials
Claude Code supports three 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, replacing
your-azure-api-keywith the key you copied:
ANTHROPIC_FOUNDRY_API_KEY nor ANTHROPIC_FOUNDRY_AUTH_TOKEN is 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:
ANTHROPIC_FOUNDRY_AUTH_TOKEN on every request as the Authorization: Bearer header. Use this option when another process, such as a host application or a sign-in script, has already obtained an access token for you. Requires Claude Code v2.1.203 or later.
Set the variable to a bearer token that Microsoft Entra ID issued for your resource:
ANTHROPIC_FOUNDRY_AUTH_TOKEN takes precedence over ANTHROPIC_FOUNDRY_API_KEY and over the default credential chain.
When using Microsoft Foundry, the
/logout command is unavailable since authentication is handled through Azure credentials.