azure-ai-foundry.md +107 −0 created
1# Claude Code on Azure AI Foundry
2
3> Learn about configuring Claude Code through Azure AI Foundry, including setup, configuration, and troubleshooting.
4
5## Prerequisites
6
7Before configuring Claude Code with Azure AI Foundry, ensure you have:
8
9* An Azure subscription with access to Azure AI Foundry
10* RBAC permissions to create Azure AI Foundry resources and deployments
11* Azure CLI installed and configured (optional - only needed if you don’t have another mechanism for getting credentials)
12
13## Setup
14
15### 1. Provision Azure AI Foundry resource
16
17First, create a Claude resource in Azure:
18
191. Navigate to the [Azure AI Foundry portal](https://ai.azure.com/)
202. Create a new resource, noting your resource name
213. Create deployments for the Claude models:
22 * Claude Opus
23 * Claude Sonnet
24 * Claude Haiku
25
26### 2. Configure Azure credentials
27
28Claude Code supports two authentication methods for Azure AI Foundry. Choose the method that best fits your security requirements.
29
30**Option A: API key authentication**
31
321. Navigate to your resource in the Azure AI Foundry portal
332. Go to the **Endpoints and keys** section
343. Copy **API Key**
354. Set the environment variable:
36
37```bash theme={null}
38export ANTHROPIC_FOUNDRY_API_KEY=your-azure-api-key
39```
40
41**Option B: Microsoft Entra ID authentication**
42
43When `ANTHROPIC_FOUNDRY_API_KEY` is not set, Claude Code automatically uses the Azure SDK [default credential chain](https://learn.microsoft.com/en-us/azure/developer/javascript/sdk/authentication/credential-chains#defaultazurecredential-overview).
44This supports a variety of methods for authenticating local and remote workloads.
45
46On local environments, you commonly may use the Azure CLI:
47
48```bash theme={null}
49az login
50```
51
52<Note>
53 When using AI Foundry, the `/login` and `/logout` commands are disabled since authentication is handled through Azure credentials.
54</Note>
55
56### 3. Configure Claude Code
57
58Set the following environment variables to enable Azure AI Foundry. Note that your deployments' names are set as the model identifiers in Claude Code (may be optional if using suggested deployment names).
59
60```bash theme={null}
61# Enable Azure AI Foundry integration
62export CLAUDE_CODE_USE_FOUNDRY=1
63
64# Azure resource name (replace {resource} with your resource name)
65export ANTHROPIC_FOUNDRY_RESOURCE={resource}
66# Or provide the full base URL:
67# export ANTHROPIC_FOUNDRY_BASE_URL=https://{resource}.services.ai.azure.com
68
69# Set models to your resource's deployment names
70export ANTHROPIC_DEFAULT_SONNET_MODEL='claude-sonnet-4-5'
71export ANTHROPIC_DEFAULT_HAIKU_MODEL='claude-haiku-4-5'
72export ANTHROPIC_DEFAULT_OPUS_MODEL='claude-opus-4-1'
73```
74
75For more details on model configuration options, see [Model configuration](/en/model-config).
76
77## Azure RBAC configuration
78
79The `Azure AI User` and `Cognitive Services User` default roles include all required permissions for invoking Claude models.
80
81For more restrictive permissions, create a custom role with the following:
82
83```json theme={null}
84{
85 "permissions": [
86 {
87 "dataActions": [
88 "Microsoft.CognitiveServices/accounts/providers/*"
89 ]
90 }
91 ]
92}
93```
94
95For details, see [Azure AI Foundry RBAC documentation](https://learn.microsoft.com/en-us/azure/ai-foundry/concepts/rbac-azure-ai-foundry).
96
97## Troubleshooting
98
99If you receive an error "Failed to get token from azureADTokenProvider: ChainedTokenCredential authentication failed":
100
101* Configure Entra ID on the environment, or set `ANTHROPIC_FOUNDRY_API_KEY`.
102
103## Additional resources
104
105* [AI Foundry documentation](https://learn.microsoft.com/en-us/azure/ai-foundry/what-is-azure-ai-foundry)
106* [AI Foundry models](https://ai.azure.com/explore/models)
107* [AI Foundry pricing](https://azure.microsoft.com/en-us/pricing/details/ai-foundry/)