Claude Code on Microsoft Foundry
--- a/microsoft-foundry.md
+++ b/microsoft-foundry.md
@@ -84,7 +84,7 @@
Pin specific model versions for every deployment. Without pinning, model aliases such as `sonnet` and `opus` resolve to Claude Code’s built-in default for Microsoft Foundry. That default can lag the newest release and may not yet be available in your account.When your resource has no deployment for the default, Claude Code switches to an older model or the request fails. A switch shows a message that starts with `Switched to <fallback> because <model> is not available`. When you create Azure deployments, select a specific model version rather than “auto-update to latest.”
-Set the model variables to match the deployment names you created in step 1. Without `ANTHROPIC_DEFAULT_OPUS_MODEL`, the `opus` alias on Microsoft Foundry resolves to Opus 4.6. Set it to the ID of a newer Opus model, such as Opus 4.8:
+Set the model variables to match the deployment names you created in step 1. Without `ANTHROPIC_DEFAULT_OPUS_MODEL`, the `opus` alias on Microsoft Foundry resolves to Opus 5.5. Before v2.1.332 it resolves to Opus 4.6. Set the variable to the ID of the Opus model you deployed, such as Opus 4.8:
export ANTHROPIC_DEFAULT_OPUS_MODEL='claude-opus-4-8'
export ANTHROPIC_DEFAULT_SONNET_MODEL='claude-sonnet-5'
--- a/microsoft-foundry.md
+++ b/microsoft-foundry.md
@@ -1,3 +1,10 @@
+This page covers setting up Microsoft Foundry for the Claude Code CLI.
+
+To use Microsoft Foundry in the **Code** tab of the Claude Desktop app, you or your administrator configures the app:
+
+ * **Your organization installed the app** : ask your administrator to [configure it for Microsoft Foundry](<https://claude.com/docs/third-party/claude-desktop/foundry>)
+ * **You install the app yourself** : follow the [single-machine setup steps](<https://claude.com/docs/third-party/claude-desktop/installation#single-machine-setup>) and enter the [connection and model values for Microsoft Foundry](<https://claude.com/docs/third-party/claude-desktop/foundry#configure-the-app>)
+
## Prerequisites
Before configuring Claude Code with Microsoft Foundry, ensure you have:
--- a/microsoft-foundry.md
+++ b/microsoft-foundry.md
@@ -95,7 +95,7 @@
claude
-Claude Code reads `CLAUDE_CODE_USE_FOUNDRY` and the other Microsoft Foundry variables from the environment and connects to your Azure resource on the first prompt. Unlike Amazon Bedrock and Google Cloud’s Agent Platform, Microsoft Foundry has no interactive setup wizard, so the environment variables in steps 3 and 4 are the only configuration path. To verify your setup, run `/status` inside Claude Code. The API provider line shows `Microsoft Foundry`, along with the resource name or base URL you configured.
+Claude Code reads `CLAUDE_CODE_USE_FOUNDRY` and the other Microsoft Foundry variables from the environment and connects to your Azure resource on the first prompt. Unlike Amazon Bedrock and Google Cloud’s Agent Platform, Microsoft Foundry has no interactive setup wizard. To verify your setup, run `/status` inside Claude Code. The API provider line shows `Microsoft Foundry`, along with the resource name or base URL you configured.
## Azure RBAC configuration
--- a/microsoft-foundry.md
+++ b/microsoft-foundry.md
@@ -115,7 +115,7 @@
}
}
-To keep a 200K window instead, set [`CLAUDE_CODE_DISABLE_1M_CONTEXT=1`](</docs/en/model-config#turn-off-1m-context>). If Claude Code can’t match a deployment name to a model, it assumes a 1M window by default, so [set the real window](</docs/en/model-config#correct-the-window-for-a-gateway-or-custom-model-id>) if your deployed model accepts less. Opus 4.6 and Sonnet 4.6 reach the 1M window when you append `[1m]` to the deployment name in `ANTHROPIC_DEFAULT_OPUS_MODEL` or `ANTHROPIC_DEFAULT_SONNET_MODEL`, as [Pin models for third-party deployments](</docs/en/model-config#pin-models-for-third-party-deployments>) describes. Before v2.1.287, the Fable models and Opus 4.7 and later also needed that suffix on Microsoft Foundry and ran with a 200K window by default without it.
+To keep a 200K window instead, set [`CLAUDE_CODE_DISABLE_1M_CONTEXT=1`](</docs/en/model-config#turn-off-1m-context>). If Claude Code can’t match a deployment name to a model, it assumes a 1M window by default, so [set the real window](</docs/en/model-config#correct-the-window-for-a-gateway-or-custom-model-id>) if your deployed model accepts less. Before v2.1.323, Claude Code assumed 200K by default, so on those versions append `[1m]` to the name in your model variables if the model accepts 1M. Opus 4.6 and Sonnet 4.6 reach the 1M window when you append `[1m]` to the deployment name in `ANTHROPIC_DEFAULT_OPUS_MODEL` or `ANTHROPIC_DEFAULT_SONNET_MODEL`, as [Pin models for third-party deployments](</docs/en/model-config#pin-models-for-third-party-deployments>) describes. Before v2.1.287, the Fable models and Opus 4.7 and later also needed that suffix on Microsoft Foundry and ran with a 200K window by default without it.
## Troubleshooting
--- a/microsoft-foundry.md
+++ b/microsoft-foundry.md
@@ -75,7 +75,7 @@
### 4\. Pin model versions
-Pin specific model versions for every deployment. Without pinning, model aliases such as `sonnet` and `opus` resolve to Claude Code’s built-in default for Microsoft Foundry, which can lag the newest release and may not yet be available in your account. Microsoft Foundry has no startup model check, so requests fail when the default is unavailable. When you create Azure deployments, select a specific model version rather than “auto-update to latest.”
+Pin specific model versions for every deployment. Without pinning, model aliases such as `sonnet` and `opus` resolve to Claude Code’s built-in default for Microsoft Foundry. That default can lag the newest release and may not yet be available in your account.When your resource has no deployment for the default, Claude Code switches to an older model or the request fails. A switch shows a message that starts with `Switched to <fallback> because <model> is not available`. When you create Azure deployments, select a specific model version rather than “auto-update to latest.”
Set the model variables to match the deployment names you created in step 1. Without `ANTHROPIC_DEFAULT_OPUS_MODEL`, the `opus` alias on Microsoft Foundry resolves to Opus 4.6. Set it to the ID of a newer Opus model, such as Opus 4.8:
--- a/microsoft-foundry.md
+++ b/microsoft-foundry.md
@@ -103,7 +103,11 @@
## 1M token context window
-On Microsoft Foundry, when Claude Code can tell which model your deployment serves, Fable models, Sonnet 5 and later, and Opus 4.7 and later run with the [1M token context window](<https://platform.claude.com/docs/en/build-with-claude/context-windows#context-window-sizes-by-model>) by default, with no `[1m]` suffix needed. Claude Code reads the model from the deployment name in your model variables. Name each deployment with its model ID, such as `claude-opus-4-8`, or map the model to your deployment name with [`modelOverrides`](</docs/en/model-config#override-model-ids-per-version>). For a deployment name it can’t match to a model, Claude Code assumes a 200K window unless you [declare a different one](</docs/en/model-config#correct-the-window-for-a-gateway-or-custom-model-id>). This `settings.json` entry tells Claude Code that a deployment named `team-opus-prod` serves Opus 4.8:
+On Microsoft Foundry, Fable models, Sonnet 5 and later, and Opus 4.7 and later run with the [1M token context window](<https://platform.claude.com/docs/en/build-with-claude/context-windows#context-window-sizes-by-model>) by default. This needs no `[1m]` suffix, as long as Claude Code can tell which model your deployment serves.
+
+Claude Code reads the model from the deployment name in your model variables. Name each deployment with its model ID, such as `claude-opus-4-8`, or map the model to your deployment name with [`modelOverrides`](</docs/en/model-config#override-model-ids-per-version>).
+
+This `settings.json` entry tells Claude Code that a deployment named `team-opus-prod` serves Opus 4.8:
{
"modelOverrides": {
@@ -111,7 +115,7 @@
}
}
-To keep a 200K window instead, set [`CLAUDE_CODE_DISABLE_1M_CONTEXT=1`](</docs/en/model-config#turn-off-1m-context>). Opus 4.6 and Sonnet 4.6 reach the 1M window when you append `[1m]` to the deployment name in `ANTHROPIC_DEFAULT_OPUS_MODEL` or `ANTHROPIC_DEFAULT_SONNET_MODEL`, as [Pin models for third-party deployments](</docs/en/model-config#pin-models-for-third-party-deployments>) describes. Before v2.1.287, the Fable models and Opus 4.7 and later also needed that suffix on Microsoft Foundry and ran with a 200K window by default without it.
+To keep a 200K window instead, set [`CLAUDE_CODE_DISABLE_1M_CONTEXT=1`](</docs/en/model-config#turn-off-1m-context>). If Claude Code can’t match a deployment name to a model, it assumes a 1M window by default, so [set the real window](</docs/en/model-config#correct-the-window-for-a-gateway-or-custom-model-id>) if your deployed model accepts less. Opus 4.6 and Sonnet 4.6 reach the 1M window when you append `[1m]` to the deployment name in `ANTHROPIC_DEFAULT_OPUS_MODEL` or `ANTHROPIC_DEFAULT_SONNET_MODEL`, as [Pin models for third-party deployments](</docs/en/model-config#pin-models-for-third-party-deployments>) describes. Before v2.1.287, the Fable models and Opus 4.7 and later also needed that suffix on Microsoft Foundry and ran with a 200K window by default without it.
## Troubleshooting
Show diff (184 lines)
--- a/microsoft-foundry.md
+++ b/microsoft-foundry.md
@@ -1,8 +1,4 @@
-##
-
-
-
-Prerequisites
+## Prerequisites
Before configuring Claude Code with Microsoft Foundry, ensure you have:
@@ -12,17 +8,9 @@
If you are deploying Claude Code to multiple users, pin your model versions before rolling out.
-##
+## Setup
-
-
-Setup
-
-###
-
-
-
-1\. Provision Microsoft Foundry resource
+### 1\. Provision Microsoft Foundry resource
First, create a Claude resource in Azure:
@@ -34,11 +22,7 @@
* Claude Haiku
When you configure a deployment, you also choose its [hosting option](<https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry#hosting-options>), which determines whether inference runs on Azure or on Anthropic infrastructure.
-###
-
-
-
-2\. Configure Azure credentials
+### 2\. Configure Azure credentials
Claude Code supports three authentication methods for Microsoft Foundry. Choose the method that best fits your security requirements:
@@ -48,11 +32,7 @@
When using Microsoft Foundry, the `/logout` command is unavailable since authentication is handled through Azure credentials.
-####
-
-
-
-Use an API key
+#### Use an API key
Copy a key from the Microsoft Foundry portal, then set it as an environment variable:
@@ -63,11 +43,7 @@
export ANTHROPIC_FOUNDRY_API_KEY=your-azure-api-key
-####
-
-
-
-Use Microsoft Entra ID
+#### Use Microsoft Entra ID
Leave `ANTHROPIC_FOUNDRY_API_KEY` and `ANTHROPIC_FOUNDRY_AUTH_TOKEN` unset. Claude Code then uses the Azure SDK [default credential chain](<https://learn.microsoft.com/en-us/azure/developer/javascript/sdk/authentication/credential-chains#defaultazurecredential-overview>). This supports a variety of methods for authenticating local and remote workloads. On a local machine, sign in with the Azure CLI:
@@ -75,11 +51,7 @@
For the roles your identity needs, see Azure RBAC configuration.
-####
-
-
-
-Use a bearer token
+#### Use a bearer token
Claude Code sends the value of `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. Set the variable to a bearer token that Microsoft Entra ID issued for your resource:
@@ -87,11 +59,7 @@
`ANTHROPIC_FOUNDRY_AUTH_TOKEN` takes precedence over `ANTHROPIC_FOUNDRY_API_KEY` and over the default credential chain.
-###
-
-
-
-3\. Configure Claude Code
+### 3\. Configure Claude Code
Set the following environment variables to enable Microsoft Foundry:
@@ -105,11 +73,7 @@
Set `ANTHROPIC_FOUNDRY_RESOURCE` to the resource name alone, such as `my-resource`. Claude Code [refuses a URL or host name](</docs/en/errors#anthropic-foundry-resource-must-be-a-foundry-resource-name>) when you send a message.
-###
-
-
-
-4\. Pin model versions
+### 4\. Pin model versions
Pin specific model versions for every deployment. Without pinning, model aliases such as `sonnet` and `opus` resolve to Claude Code’s built-in default for Microsoft Foundry, which can lag the newest release and may not yet be available in your account. Microsoft Foundry has no startup model check, so requests fail when the default is unavailable. When you create Azure deployments, select a specific model version rather than “auto-update to latest.”
@@ -125,11 +89,7 @@
To set different TTLs for your main conversation and for the requests Claude Code makes outside it, [choose the TTL yourself](</docs/en/prompt-caching#choose-the-ttl-yourself>).
-###
-
-
-
-5\. Run Claude Code
+### 5\. Run Claude Code
With the environment variables set, start Claude Code from your project directory:
@@ -137,31 +97,11 @@
Claude Code reads `CLAUDE_CODE_USE_FOUNDRY` and the other Microsoft Foundry variables from the environment and connects to your Azure resource on the first prompt. Unlike Amazon Bedrock and Google Cloud’s Agent Platform, Microsoft Foundry has no interactive setup wizard, so the environment variables in steps 3 and 4 are the only configuration path. To verify your setup, run `/status` inside Claude Code. The API provider line shows `Microsoft Foundry`, along with the resource name or base URL you configured.
-##
+## Azure RBAC configuration
-
+If you authenticate with Microsoft Entra ID or a bearer token it issued, assign your identity the `Foundry User` or `Cognitive Services User` role on your Foundry resource. You might still see `Foundry User` under its previous name, `Azure AI User`. If these roles don’t meet your needs, see [Microsoft Foundry RBAC documentation](<https://learn.microsoft.com/en-us/azure/foundry/concepts/rbac-foundry>) for custom roles.
-Azure RBAC configuration
-
-The `Azure 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:
-
- {
- "permissions": [
- {
- "dataActions": [
- "Microsoft.CognitiveServices/accounts/providers/*"
- ]
- }
- ]
- }
-
-For details, see [Microsoft Foundry RBAC documentation](<https://learn.microsoft.com/en-us/azure/ai-foundry/concepts/rbac-azure-ai-foundry>).
-
-##
-
-
-
-1M token context window
+## 1M token context window
On Microsoft Foundry, when Claude Code can tell which model your deployment serves, Fable models, Sonnet 5 and later, and Opus 4.7 and later run with the [1M token context window](<https://platform.claude.com/docs/en/build-with-claude/context-windows#context-window-sizes-by-model>) by default, with no `[1m]` suffix needed. Claude Code reads the model from the deployment name in your model variables. Name each deployment with its model ID, such as `claude-opus-4-8`, or map the model to your deployment name with [`modelOverrides`](</docs/en/model-config#override-model-ids-per-version>). For a deployment name it can’t match to a model, Claude Code assumes a 200K window unless you [declare a different one](</docs/en/model-config#correct-the-window-for-a-gateway-or-custom-model-id>). This `settings.json` entry tells Claude Code that a deployment named `team-opus-prod` serves Opus 4.8:
@@ -173,11 +113,7 @@
To keep a 200K window instead, set [`CLAUDE_CODE_DISABLE_1M_CONTEXT=1`](</docs/en/model-config#turn-off-1m-context>). Opus 4.6 and Sonnet 4.6 reach the 1M window when you append `[1m]` to the deployment name in `ANTHROPIC_DEFAULT_OPUS_MODEL` or `ANTHROPIC_DEFAULT_SONNET_MODEL`, as [Pin models for third-party deployments](</docs/en/model-config#pin-models-for-third-party-deployments>) describes. Before v2.1.287, the Fable models and Opus 4.7 and later also needed that suffix on Microsoft Foundry and ran with a 200K window by default without it.
-##
-
-
-
-Troubleshooting
+## Troubleshooting
If you receive an error “Failed to get token from azureADTokenProvider: ChainedTokenCredential authentication failed”:
@@ -187,11 +123,7 @@
* Check that `ANTHROPIC_FOUNDRY_RESOURCE` is set to your actual resource name rather than a placeholder. Claude Code builds the endpoint URL from this value, so an incorrect name points at a host that doesn’t exist.
-##
-
-
-
-Additional resources
+## Additional resources
* [Microsoft Foundry documentation](<https://learn.microsoft.com/en-us/azure/ai-foundry/what-is-azure-ai-foundry>)
* [Microsoft Foundry models](<https://ai.azure.com/explore/models>)
--- a/microsoft-foundry.md
+++ b/microsoft-foundry.md
@@ -81,7 +81,7 @@
Use a bearer token
-Claude Code sends the value of `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:
+Claude Code sends the value of `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. Set the variable to a bearer token that Microsoft Entra ID issued for your resource:
export ANTHROPIC_FOUNDRY_AUTH_TOKEN=your-entra-access-token
--- a/microsoft-foundry.md
+++ b/microsoft-foundry.md
@@ -161,6 +161,22 @@
+1M token context window
+
+On Microsoft Foundry, when Claude Code can tell which model your deployment serves, Fable models, Sonnet 5 and later, and Opus 4.7 and later run with the [1M token context window](<https://platform.claude.com/docs/en/build-with-claude/context-windows#context-window-sizes-by-model>) by default, with no `[1m]` suffix needed. Claude Code reads the model from the deployment name in your model variables. Name each deployment with its model ID, such as `claude-opus-4-8`, or map the model to your deployment name with [`modelOverrides`](</docs/en/model-config#override-model-ids-per-version>). For a deployment name it can’t match to a model, Claude Code assumes a 200K window unless you [declare a different one](</docs/en/model-config#correct-the-window-for-a-gateway-or-custom-model-id>). This `settings.json` entry tells Claude Code that a deployment named `team-opus-prod` serves Opus 4.8:
+
+ {
+ "modelOverrides": {
+ "claude-opus-4-8": "team-opus-prod"
+ }
+ }
+
+To keep a 200K window instead, set [`CLAUDE_CODE_DISABLE_1M_CONTEXT=1`](</docs/en/model-config#turn-off-1m-context>). Opus 4.6 and Sonnet 4.6 reach the 1M window when you append `[1m]` to the deployment name in `ANTHROPIC_DEFAULT_OPUS_MODEL` or `ANTHROPIC_DEFAULT_SONNET_MODEL`, as [Pin models for third-party deployments](</docs/en/model-config#pin-models-for-third-party-deployments>) describes. Before v2.1.287, the Fable models and Opus 4.7 and later also needed that suffix on Microsoft Foundry and ran with a 200K window by default without it.
+
+##
+
+
+
Troubleshooting
If you receive an error “Failed to get token from azureADTokenProvider: ChainedTokenCredential authentication failed”:
--- a/microsoft-foundry.md
+++ b/microsoft-foundry.md
@@ -40,26 +40,52 @@
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**
+Claude Code supports three authentication methods for Microsoft Foundry. Choose the method that best fits your security requirements:
- 1. Navigate to your resource in the Microsoft Foundry portal
- 2. Go to the **Endpoints and keys** section
+ * API key: you copy a key from the Microsoft Foundry portal and set it as `ANTHROPIC_FOUNDRY_API_KEY`
+ * Microsoft Entra ID: Claude Code gets tokens through the Azure SDK default credential chain, for example from an `az login` session, so there’s no API key to store
+ * Bearer token: another process obtains a Microsoft Entra ID access token and you pass it in `ANTHROPIC_FOUNDRY_AUTH_TOKEN`
+
+When using Microsoft Foundry, the `/logout` command is unavailable since authentication is handled through Azure credentials.
+
+####
+
+
+
+Use an API key
+
+Copy a key from the Microsoft Foundry portal, then set it as an environment variable:
+
+ 1. Go to your resource in the Microsoft Foundry portal
+ 2. Open the **Endpoints and keys** section
3. Copy **API Key**
4. Set the environment variable, replacing `your-azure-api-key` with the key you copied:
export ANTHROPIC_FOUNDRY_API_KEY=your-azure-api-key
-**Option B: Microsoft Entra ID authentication** When neither `ANTHROPIC_FOUNDRY_API_KEY` nor `ANTHROPIC_FOUNDRY_AUTH_TOKEN` is 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>). This supports a variety of methods for authenticating local and remote workloads. On local environments, you commonly may use the Azure CLI:
+####
+
+
+
+Use Microsoft Entra ID
+
+Leave `ANTHROPIC_FOUNDRY_API_KEY` and `ANTHROPIC_FOUNDRY_AUTH_TOKEN` unset. Claude Code then uses the Azure SDK [default credential chain](<https://learn.microsoft.com/en-us/azure/developer/javascript/sdk/authentication/credential-chains#defaultazurecredential-overview>). This supports a variety of methods for authenticating local and remote workloads. On a local machine, sign in with the Azure CLI:
az login
-**Option C: Bearer token authentication** Claude Code sends the value of `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:
+For the roles your identity needs, see Azure RBAC configuration.
+
+####
+
+
+
+Use a bearer token
+
+Claude Code sends the value of `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:
export ANTHROPIC_FOUNDRY_AUTH_TOKEN=your-entra-access-token
`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.
###
--- a/microsoft-foundry.md
+++ b/microsoft-foundry.md
@@ -77,6 +77,8 @@
# Or provide the full base URL:
# export ANTHROPIC_FOUNDRY_BASE_URL=https://{resource}.services.ai.azure.com/anthropic
+Set `ANTHROPIC_FOUNDRY_RESOURCE` to the resource name alone, such as `my-resource`. Claude Code [refuses a URL or host name](</docs/en/errors#anthropic-foundry-resource-must-be-a-foundry-resource-name>) when you send a message.
+
###
--- a/microsoft-foundry.md
+++ b/microsoft-foundry.md
@@ -26,7 +26,7 @@
First, create a Claude resource in Azure:
- 1. Navigate to the [Microsoft Foundry portal](<https://ai.azure.com/>)
+ 1. Go to the [Microsoft Foundry portal](<https://ai.azure.com/>)
2. Create a new resource, noting your resource name
3. 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
--- a/microsoft-foundry.md
+++ b/microsoft-foundry.md
@@ -95,6 +95,8 @@
export ENABLE_PROMPT_CACHING_1H=1
+To set different TTLs for your main conversation and for the requests Claude Code makes outside it, [choose the TTL yourself](</docs/en/prompt-caching#choose-the-ttl-yourself>).
+
###
--- a/microsoft-foundry.md
+++ b/microsoft-foundry.md
@@ -85,7 +85,7 @@
Pin specific model versions for every deployment. Without pinning, model aliases such as `sonnet` and `opus` resolve to Claude Code’s built-in default for Microsoft Foundry, which can lag the newest release and may not yet be available in your account. Microsoft Foundry has no startup model check, so requests fail when the default is unavailable. When you create Azure deployments, select a specific model version rather than “auto-update to latest.”
-Set the model variables to match the deployment names you created in step 1. Without `ANTHROPIC_DEFAULT_OPUS_MODEL`, the `opus` alias on Microsoft Foundry resolves to Opus 4.6. Set it to the Opus 4.8 ID to use the latest model:
+Set the model variables to match the deployment names you created in step 1. Without `ANTHROPIC_DEFAULT_OPUS_MODEL`, the `opus` alias on Microsoft Foundry resolves to Opus 4.6. Set it to the ID of a newer Opus model, such as Opus 4.8:
export ANTHROPIC_DEFAULT_OPUS_MODEL='claude-opus-4-8'
export ANTHROPIC_DEFAULT_SONNET_MODEL='claude-sonnet-5'
--- a/microsoft-foundry.md
+++ b/microsoft-foundry.md
@@ -32,6 +32,7 @@
* Claude Opus
* Claude Sonnet
* Claude Haiku
+When you configure a deployment, you also choose its [hosting option](<https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry#hosting-options>), which determines whether inference runs on Azure or on Anthropic infrastructure.
###
--- a/microsoft-foundry.md
+++ b/microsoft-foundry.md
@@ -28,7 +28,7 @@
1. Navigate to the [Microsoft Foundry portal](<https://ai.azure.com/>)
2. Create a new resource, noting your resource name
- 3. Create deployments for the Claude models:
+ 3. 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
@@ -44,7 +44,7 @@
1. Navigate to your resource in the Microsoft Foundry portal
2. Go to the **Endpoints and keys** section
3. Copy **API Key**
- 4. Set the environment variable:
+ 4. Set the environment variable, replacing `your-azure-api-key` with the key you copied:
export ANTHROPIC_FOUNDRY_API_KEY=your-azure-api-key
@@ -104,7 +104,7 @@
claude
-Claude Code reads `CLAUDE_CODE_USE_FOUNDRY` and the other Microsoft Foundry variables from the environment and connects to your Azure resource on the first prompt. Unlike Amazon Bedrock and Google Cloud’s Agent Platform, Microsoft Foundry has no interactive setup wizard, so the environment variables in steps 3 and 4 are the only configuration path.
+Claude Code reads `CLAUDE_CODE_USE_FOUNDRY` and the other Microsoft Foundry variables from the environment and connects to your Azure resource on the first prompt. Unlike Amazon Bedrock and Google Cloud’s Agent Platform, Microsoft Foundry has no interactive setup wizard, so the environment variables in steps 3 and 4 are the only configuration path. To verify your setup, run `/status` inside Claude Code. The API provider line shows `Microsoft Foundry`, along with the resource name or base URL you configured.
##
@@ -136,6 +136,10 @@
* Configure Entra ID on the environment, or set `ANTHROPIC_FOUNDRY_API_KEY`.
+If requests fail with repeated connection errors on the first prompt:
+
+ * Check that `ANTHROPIC_FOUNDRY_RESOURCE` is set to your actual resource name rather than a placeholder. Claude Code builds the endpoint URL from this value, so an incorrect name points at a host that doesn’t exist.
+
##
--- a/microsoft-foundry.md
+++ b/microsoft-foundry.md
@@ -39,7 +39,7 @@
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**
+Claude Code supports three authentication methods for Microsoft Foundry. Choose the method that best fits your security requirements. **Option A: API key authentication**
1. Navigate to your resource in the Microsoft Foundry portal
2. Go to the **Endpoints and keys** section
@@ -48,9 +48,15 @@
export ANTHROPIC_FOUNDRY_API_KEY=your-azure-api-key
-**Option B: Microsoft Entra ID authentication** When `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>). This supports a variety of methods for authenticating local and remote workloads. On local environments, you commonly may use the Azure CLI:
+**Option B: Microsoft Entra ID authentication** When neither `ANTHROPIC_FOUNDRY_API_KEY` nor `ANTHROPIC_FOUNDRY_AUTH_TOKEN` is 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>). This supports a variety of methods for authenticating local and remote workloads. On local environments, you commonly may use the Azure CLI:
az login
+
+**Option C: Bearer token authentication** Claude Code sends the value of `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:
+
+ export ANTHROPIC_FOUNDRY_AUTH_TOKEN=your-entra-access-token
+
+`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.
--- a/microsoft-foundry.md
+++ b/microsoft-foundry.md
@@ -76,15 +76,15 @@
4\. Pin model versions
-Pin specific model versions for every deployment. Without pinning, model aliases such as `sonnet` and `opus` resolve to Claude Code’s built-in default for Foundry, which can lag the newest release and may not yet be available in your account. Foundry has no startup model check, so requests fail when the default is unavailable. When you create Azure deployments, select a specific model version rather than “auto-update to latest.”
+Pin specific model versions for every deployment. Without pinning, model aliases such as `sonnet` and `opus` resolve to Claude Code’s built-in default for Microsoft Foundry, which can lag the newest release and may not yet be available in your account. Microsoft Foundry has no startup model check, so requests fail when the default is unavailable. When you create Azure deployments, select a specific model version rather than “auto-update to latest.”
-Set the model variables to match the deployment names you created in step 1. Without `ANTHROPIC_DEFAULT_OPUS_MODEL`, the `opus` alias on Foundry resolves to Opus 4.6. Set it to the Opus 4.8 ID to use the latest model:
+Set the model variables to match the deployment names you created in step 1. Without `ANTHROPIC_DEFAULT_OPUS_MODEL`, the `opus` alias on Microsoft Foundry resolves to Opus 4.6. Set it to the Opus 4.8 ID to use the latest model:
export ANTHROPIC_DEFAULT_OPUS_MODEL='claude-opus-4-8'
export ANTHROPIC_DEFAULT_SONNET_MODEL='claude-sonnet-5'
export ANTHROPIC_DEFAULT_HAIKU_MODEL='claude-haiku-4-5'
-Background tasks such as session title generation use the small/fast model, normally a Haiku-class model. On Foundry, Claude Code defaults this to the primary model because not every account has a Haiku deployment. To use Haiku for background tasks, set `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](<https://platform.claude.com/docs/en/about-claude/models/overview>). See [Model configuration](</docs/en/model-config#pin-models-for-third-party-deployments>) for the full list of environment variables. [Prompt caching](</docs/en/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:
+Background tasks such as session title generation use the small/fast model, normally a Haiku-class model. On Microsoft Foundry, Claude Code defaults this to the primary model because not every account has a Haiku deployment. To use Haiku for background tasks, set `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](<https://platform.claude.com/docs/en/about-claude/models/overview>). See [Model configuration](</docs/en/model-config#pin-models-for-third-party-deployments>) for the full list of environment variables. [Prompt caching](</docs/en/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:
export ENABLE_PROMPT_CACHING_1H=1
@@ -98,7 +98,7 @@
claude
-Claude Code reads `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.
+Claude Code reads `CLAUDE_CODE_USE_FOUNDRY` and the other Microsoft Foundry variables from the environment and connects to your Azure resource on the first prompt. Unlike Amazon Bedrock and Google Cloud’s Agent Platform, Microsoft Foundry has no interactive setup wizard, so the environment variables in steps 3 and 4 are the only configuration path.
##
--- a/microsoft-foundry.md
+++ b/microsoft-foundry.md
@@ -81,7 +81,7 @@
Set the model variables to match the deployment names you created in step 1. Without `ANTHROPIC_DEFAULT_OPUS_MODEL`, the `opus` alias on Foundry resolves to Opus 4.6. Set it to the Opus 4.8 ID to use the latest model:
export ANTHROPIC_DEFAULT_OPUS_MODEL='claude-opus-4-8'
- export ANTHROPIC_DEFAULT_SONNET_MODEL='claude-sonnet-4-6'
+ export ANTHROPIC_DEFAULT_SONNET_MODEL='claude-sonnet-5'
export ANTHROPIC_DEFAULT_HAIKU_MODEL='claude-haiku-4-5'
Background tasks such as session title generation use the small/fast model, normally a Haiku-class model. On Foundry, Claude Code defaults this to the primary model because not every account has a Haiku deployment. To use Haiku for background tasks, set `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](<https://platform.claude.com/docs/en/about-claude/models/overview>). See [Model configuration](</docs/en/model-config#pin-models-for-third-party-deployments>) for the full list of environment variables. [Prompt caching](</docs/en/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:
--- a/microsoft-foundry.md
+++ b/microsoft-foundry.md
@@ -10,7 +10,7 @@
* 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.
+If you are deploying Claude Code to multiple users, pin your model versions before rolling out.
##
@@ -76,7 +76,7 @@
4\. Pin model versions
-Pin specific model versions for every deployment. If you use model aliases (`sonnet`, `opus`, `haiku`) without pinning, Claude Code may attempt to use a newer model version that isn’t available in your Foundry account, breaking existing users when Anthropic releases updates. When you create Azure deployments, select a specific model version rather than “auto-update to latest.”
+Pin specific model versions for every deployment. Without pinning, model aliases such as `sonnet` and `opus` resolve to Claude Code’s built-in default for Foundry, which can lag the newest release and may not yet be available in your account. Foundry has no startup model check, so requests fail when the default is unavailable. When you create Azure deployments, select a specific model version rather than “auto-update to latest.”
Set the model variables to match the deployment names you created in step 1. Without `ANTHROPIC_DEFAULT_OPUS_MODEL`, the `opus` alias on Foundry resolves to Opus 4.6. Set it to the Opus 4.8 ID to use the latest model:
--- a/microsoft-foundry.md
+++ b/microsoft-foundry.md
@@ -1,9 +1,3 @@
-> ## 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.
-
##
--- a/microsoft-foundry.md
+++ b/microsoft-foundry.md
@@ -84,9 +84,9 @@
Pin specific model versions for every deployment. If you use model aliases (`sonnet`, `opus`, `haiku`) without pinning, Claude Code may attempt to use a newer model version that isn’t available in your Foundry account, breaking existing users when Anthropic releases updates. When you create Azure deployments, select a specific model version rather than “auto-update to latest.”
-Set the model variables to match the deployment names you created in step 1. Without `ANTHROPIC_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:
+Set the model variables to match the deployment names you created in step 1. Without `ANTHROPIC_DEFAULT_OPUS_MODEL`, the `opus` alias on Foundry resolves to Opus 4.6. Set it to the Opus 4.8 ID to use the latest model:
- export ANTHROPIC_DEFAULT_OPUS_MODEL='claude-opus-4-7'
+ export ANTHROPIC_DEFAULT_OPUS_MODEL='claude-opus-4-8'
export ANTHROPIC_DEFAULT_SONNET_MODEL='claude-sonnet-4-6'
export ANTHROPIC_DEFAULT_HAIKU_MODEL='claude-haiku-4-5'
--- a/microsoft-foundry.md
+++ b/microsoft-foundry.md
@@ -58,7 +58,7 @@
az login
-When using Microsoft Foundry, the `/login` and `/logout` commands are disabled since authentication is handled through Azure credentials.
+When using Microsoft Foundry, the `/logout` command is unavailable since authentication is handled through Azure credentials.
###
--- a/microsoft-foundry.md
+++ b/microsoft-foundry.md
@@ -90,7 +90,7 @@
export ANTHROPIC_DEFAULT_SONNET_MODEL='claude-sonnet-4-6'
export ANTHROPIC_DEFAULT_HAIKU_MODEL='claude-haiku-4-5'
-Background tasks such as session title generation use the small/fast model, normally a Haiku-class model. On Foundry, Claude Code defaults this to the primary model because not every account has a Haiku deployment. To use Haiku for background tasks, set `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](<https://platform.claude.com/docs/en/about-claude/models/overview>). See [Model configuration](</docs/en/model-config#pin-models-for-third-party-deployments>) for the full list of environment variables. [Prompt caching](<https://platform.claude.com/docs/en/build-with-claude/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:
+Background tasks such as session title generation use the small/fast model, normally a Haiku-class model. On Foundry, Claude Code defaults this to the primary model because not every account has a Haiku deployment. To use Haiku for background tasks, set `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](<https://platform.claude.com/docs/en/about-claude/models/overview>). See [Model configuration](</docs/en/model-config#pin-models-for-third-party-deployments>) for the full list of environment variables. [Prompt caching](</docs/en/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:
export ENABLE_PROMPT_CACHING_1H=1
--- a/microsoft-foundry.md
+++ b/microsoft-foundry.md
@@ -94,6 +94,18 @@
export ENABLE_PROMPT_CACHING_1H=1
+###
+
+
+
+5\. Run Claude Code
+
+With the environment variables set, start Claude Code from your project directory:
+
+ claude
+
+Claude Code reads `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.
+
##
--- a/microsoft-foundry.md
+++ b/microsoft-foundry.md
@@ -90,7 +90,7 @@
export ANTHROPIC_DEFAULT_SONNET_MODEL='claude-sonnet-4-6'
export ANTHROPIC_DEFAULT_HAIKU_MODEL='claude-haiku-4-5'
-For current and legacy model IDs, see [Models overview](<https://platform.claude.com/docs/en/about-claude/models/overview>). See [Model configuration](</docs/en/model-config#pin-models-for-third-party-deployments>) for the full list of environment variables. [Prompt caching](<https://platform.claude.com/docs/en/build-with-claude/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:
+Background tasks such as session title generation use the small/fast model, normally a Haiku-class model. On Foundry, Claude Code defaults this to the primary model because not every account has a Haiku deployment. To use Haiku for background tasks, set `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](<https://platform.claude.com/docs/en/about-claude/models/overview>). See [Model configuration](</docs/en/model-config#pin-models-for-third-party-deployments>) for the full list of environment variables. [Prompt caching](<https://platform.claude.com/docs/en/build-with-claude/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:
export ENABLE_PROMPT_CACHING_1H=1
--- a/microsoft-foundry.md
+++ b/microsoft-foundry.md
@@ -1,3 +1,9 @@
+> ## 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.
+
##
--- a/microsoft-foundry.md
+++ b/microsoft-foundry.md
@@ -84,7 +84,9 @@
export ANTHROPIC_DEFAULT_SONNET_MODEL='claude-sonnet-4-6'
export ANTHROPIC_DEFAULT_HAIKU_MODEL='claude-haiku-4-5'
-For current and legacy model IDs, see [Models overview](<https://platform.claude.com/docs/en/about-claude/models/overview>). See [Model configuration](</docs/en/model-config#pin-models-for-third-party-deployments>) for the full list of environment variables.
+For current and legacy model IDs, see [Models overview](<https://platform.claude.com/docs/en/about-claude/models/overview>). See [Model configuration](</docs/en/model-config#pin-models-for-third-party-deployments>) for the full list of environment variables. [Prompt caching](<https://platform.claude.com/docs/en/build-with-claude/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:
+
+ export ENABLE_PROMPT_CACHING_1H=1
##
--- a/microsoft-foundry.md
+++ b/microsoft-foundry.md
@@ -78,9 +78,9 @@
Pin specific model versions for every deployment. If you use model aliases (`sonnet`, `opus`, `haiku`) without pinning, Claude Code may attempt to use a newer model version that isn’t available in your Foundry account, breaking existing users when Anthropic releases updates. When you create Azure deployments, select a specific model version rather than “auto-update to latest.”
-Set the model variables to match the deployment names you created in step 1:
+Set the model variables to match the deployment names you created in step 1. Without `ANTHROPIC_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:
- export ANTHROPIC_DEFAULT_OPUS_MODEL='claude-opus-4-6'
+ export ANTHROPIC_DEFAULT_OPUS_MODEL='claude-opus-4-7'
export ANTHROPIC_DEFAULT_SONNET_MODEL='claude-sonnet-4-6'
export ANTHROPIC_DEFAULT_HAIKU_MODEL='claude-haiku-4-5'
--- a/microsoft-foundry.md
+++ b/microsoft-foundry.md
@@ -46,21 +46,9 @@
3. Copy **API Key**
4. Set the environment variable:
-Report incorrect code
-
-Copy
-
-Ask AI
-
export ANTHROPIC_FOUNDRY_API_KEY=your-azure-api-key
**Option B: Microsoft Entra ID authentication** When `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>). This supports a variety of methods for authenticating local and remote workloads. On local environments, you commonly may use the Azure CLI:
-
-Report incorrect code
-
-Copy
-
-Ask AI
az login
@@ -73,12 +61,6 @@
3\. Configure Claude Code
Set the following environment variables to enable Microsoft Foundry:
-
-Report incorrect code
-
-Copy
-
-Ask AI
# Enable Microsoft Foundry integration
export CLAUDE_CODE_USE_FOUNDRY=1
@@ -98,12 +80,6 @@
Set the model variables to match the deployment names you created in step 1:
-Report incorrect code
-
-Copy
-
-Ask AI
-
export ANTHROPIC_DEFAULT_OPUS_MODEL='claude-opus-4-6'
export ANTHROPIC_DEFAULT_SONNET_MODEL='claude-sonnet-4-6'
export ANTHROPIC_DEFAULT_HAIKU_MODEL='claude-haiku-4-5'
@@ -117,12 +93,6 @@
Azure RBAC configuration
The `Azure 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:
-
-Report incorrect code
-
-Copy
-
-Ask AI
{
"permissions": [
Show diff (160 lines)
--- a/microsoft-foundry.md
+++ b/microsoft-foundry.md
@@ -0,0 +1,157 @@
+##
+
+
+
+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:
+
+ 1. Navigate to the [Microsoft Foundry portal](<https://ai.azure.com/>)
+ 2. Create a new resource, noting your resource name
+ 3. 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**
+
+ 1. Navigate to your resource in the Microsoft Foundry portal
+ 2. Go to the **Endpoints and keys** section
+ 3. Copy **API Key**
+ 4. Set the environment variable:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ export ANTHROPIC_FOUNDRY_API_KEY=your-azure-api-key
+
+**Option B: Microsoft Entra ID authentication** When `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>). This supports a variety of methods for authenticating local and remote workloads. On local environments, you commonly may use the Azure CLI:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ az login
+
+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:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ # Enable Microsoft Foundry integration
+ export CLAUDE_CODE_USE_FOUNDRY=1
+
+ # Azure resource name (replace {resource} with your resource name)
+ export ANTHROPIC_FOUNDRY_RESOURCE={resource}
+ # Or provide the full base URL:
+ # export ANTHROPIC_FOUNDRY_BASE_URL=https://{resource}.services.ai.azure.com/anthropic
+
+###
+
+
+
+4\. Pin model versions
+
+Pin specific model versions for every deployment. If you use model aliases (`sonnet`, `opus`, `haiku`) without pinning, Claude Code may attempt to use a newer model version that isn’t available in your Foundry account, breaking existing users when Anthropic releases updates. When you create Azure deployments, select a specific model version rather than “auto-update to latest.”
+
+Set the model variables to match the deployment names you created in step 1:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ export ANTHROPIC_DEFAULT_OPUS_MODEL='claude-opus-4-6'
+ export ANTHROPIC_DEFAULT_SONNET_MODEL='claude-sonnet-4-6'
+ export ANTHROPIC_DEFAULT_HAIKU_MODEL='claude-haiku-4-5'
+
+For current and legacy model IDs, see [Models overview](<https://platform.claude.com/docs/en/about-claude/models/overview>). See [Model configuration](</docs/en/model-config#pin-models-for-third-party-deployments>) for the full list of environment variables.
+
+##
+
+
+
+Azure RBAC configuration
+
+The `Azure 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:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ {
+ "permissions": [
+ {
+ "dataActions": [
+ "Microsoft.CognitiveServices/accounts/providers/*"
+ ]
+ }
+ ]
+ }
+
+For details, see [Microsoft Foundry RBAC documentation](<https://learn.microsoft.com/en-us/azure/ai-foundry/concepts/rbac-azure-ai-foundry>).
+
+##
+
+
+
+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`.
+
+##
+
+
+
+Additional resources
+
+ * [Microsoft Foundry documentation](<https://learn.microsoft.com/en-us/azure/ai-foundry/what-is-azure-ai-foundry>)
+ * [Microsoft Foundry models](<https://ai.azure.com/explore/models>)
+ * [Microsoft Foundry pricing](<https://azure.microsoft.com/en-us/pricing/details/ai-foundry/>)