In short.
This guide helps developers and Azure administrators connect Claude Code to Microsoft Foundry, but incorrect deployment names or unpinned models can cause fallback to an older model or failed requests. It documents API-key, Microsoft Entra ID and bearer-token authentication, along with resource configuration, background-model selection, caching and context-window behavior. The deployment's hosting option determines whether inference runs on Azure or Anthropic infrastructure. Prices, account-specific model availability and operational performance are not established by the page, and nothing was executed.
Researched and written by an AI model and checked by a second AI model. How it works
Coverage includes the complete selected page at [https://code.claude.com/docs/en/microsoft-foundry.md]: the Desktop notice, prerequisites, provisioning, authentication, environment settings, model-pinning warning, caching, Azure roles, context-window exceptions and troubleshooting. Linked pages are excluded. Their presence does not establish their contents, prices, rights or account-specific availability. All operational behavior is described from the documentation; nothing was executed or tested.
The overview
identity
This Claude Code documentation page explains how to configure the command-line coding assistant to connect through Microsoft Foundry. Its original address is [https://code.claude.com/docs/en/microsoft-foundry.md].
The instructions cover the CLI. A separate notice directs Claude Desktop users to administrator or single-machine configuration guides; those linked guides are outside the available evidence.
assessment
The guide is useful for developers configuring an existing Azure environment and administrators preparing a rollout. It gives concrete environment variables, authentication choices, role names and diagnostic steps.
Its strongest practical value is explaining configuration traps: authentication precedence, resource-name formatting, model aliases and context-window assumptions. It supports planning and configuration, but supplies no measured evidence of reliability, coding quality or performance.
users
The intended readers include individual developers using Claude Code, Azure administrators creating resources and deployments, and teams distributing configuration to multiple users. The page specifically recommends pinning model versions before an organizational rollout.
Beginners need familiarity with shell environment variables, Azure resources and access roles. Experienced developers will find details about credential precedence, custom deployment names, background requests and version-dependent context handling.
capabilities
The documented integration supports authentication through an API key, the Azure SDK default credential chain or an externally obtained Microsoft Entra ID bearer token. Model variables select Opus, Sonnet and Haiku deployments. Background tasks normally use the primary model on Foundry unless an available Haiku deployment is configured.
Prompt caching is enabled automatically with a five-minute default lifetime. ENABLE_PROMPT_CACHING_1H=1 requests a one-hour lifetime, whose cache writes cost more.
The page states that Fable models, Sonnet 5 and later, and Opus 4.7 and later use a one-million-token context window by default when Claude Code recognizes the deployed model. CLAUDE_CODE_DISABLE_1M_CONTEXT=1 keeps a 200,000-token window instead. Opus 4.6 and Sonnet 4.6 require a [1m] suffix on their configured deployment names to reach one million tokens.
Using it
requirements
The stated prerequisites are an Azure subscription with Microsoft Foundry access and role-based access control permissions to create resources and deployments. Azure CLI is optional if another mechanism supplies credentials. An available Claude Code CLI is also needed; its installation is not explained here.
For Microsoft Entra ID authentication, including Entra-issued bearer tokens, the page specifies the Foundry User or Cognitive Services User role on the Foundry resource. Foundry User may still appear under its former name, Azure AI User.
The page does not establish supported operating systems, a minimum CLI version for the integration, regional availability, quotas or which models a particular subscription can deploy.
mechanism
CLAUDE_CODE_USE_FOUNDRY=1 enables the integration. Claude Code reads the resource and authentication settings from its environment and connects on the first prompt. ANTHROPIC_FOUNDRY_RESOURCE takes a resource name, while ANTHROPIC_FOUNDRY_BASE_URL accepts a full endpoint such as [https://my-resource.services.ai.azure.com/anthropic].
ANTHROPIC_FOUNDRY_AUTH_TOKEN is sent in the Authorization: Bearer header on every request and overrides both ANTHROPIC_FOUNDRY_API_KEY and the default credential chain. Leaving both explicit credentials unset enables the Azure SDK default credential chain, which can use an Azure CLI login.
Deployment names also tell Claude Code which model and context limits to use. A modelOverrides entry can map a model identifier to a custom deployment name. Separately, the hosting option selected during deployment determines whether inference runs on Azure or Anthropic infrastructure.
setup
Create a Claude resource through the Microsoft Foundry portal at [https://ai.azure.com/], then create the required model deployments and record their names. Choose specific model versions rather than automatic updates, and select the appropriate hosting option.
Configure one authentication path: copy an API key into ANTHROPIC_FOUNDRY_API_KEY, leave both credential variables unset and configure Entra authentication, or supply an Entra access token through ANTHROPIC_FOUNDRY_AUTH_TOKEN. Set CLAUDE_CODE_USE_FOUNDRY=1 and either the resource name or full base URL. ANTHROPIC_FOUNDRY_RESOURCE must contain the name alone; Claude Code rejects a URL or hostname in that variable.
Set ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL and ANTHROPIC_DEFAULT_HAIKU_MODEL to the applicable deployment names. Start claude from the project directory. The documented verification step is /status, whose API provider line should show Microsoft Foundry and the configured resource or base URL.
example
For an illustrative resource named my-resource with deployments actually named claude-opus-4-8, claude-sonnet-5 and claude-haiku-4-5, an Entra-based setup starts with an appropriately authorized identity. Leave ANTHROPIC_FOUNDRY_API_KEY and ANTHROPIC_FOUNDRY_AUTH_TOKEN unset, then authenticate locally with az login.
Set CLAUDE_CODE_USE_FOUNDRY=1, ANTHROPIC_FOUNDRY_RESOURCE=my-resource, ANTHROPIC_DEFAULT_OPUS_MODEL=claude-opus-4-8, ANTHROPIC_DEFAULT_SONNET_MODEL=claude-sonnet-5 and ANTHROPIC_DEFAULT_HAIKU_MODEL=claude-haiku-4-5 in the shell environment. These model identifiers are examples from the page; their availability in an individual account is unknown.
For a custom deployment named team-opus-prod serving Opus 4.8, the page shows a settings.json modelOverrides mapping from claude-opus-4-8 to team-opus-prod. This lets Claude Code recognize the model behind the custom name. No example was executed.
Assessment & evidence
limitations
Microsoft Foundry has no interactive Claude Code setup wizard. The /logout command is unavailable because authentication is handled through Azure credentials. Claude Desktop requires separate configuration.
Unpinned model aliases can resolve to defaults that lag newer releases or are unavailable in the account. The page states that the unconfigured opus alias resolves to Opus 4.6. Missing deployments can trigger an older-model fallback or a failed request.
Unrecognized deployment names cause Claude Code to assume a one-million-token window in the documented newer behavior; a smaller deployed model needs its real limit configured. Data retention, regional processing guarantees, throughput and operational reliability are not established here.
reasoning
This guide is a practical fit when a team already wants to use Foundry and can manage Azure identity and model deployments. Its explicit settings make the connection understandable, while its warnings explain why apparently valid aliases can still select an unintended model.
Pinning both the Azure deployment version and Claude Code's deployment variables addresses the documented fallback risk. Recognizable deployment names or modelOverrides address context-window interpretation. Choosing Azure authentication alone does not establish where inference runs, because the deployment's hosting option controls that separately.
The evidence supports these configuration conclusions. It does not support claims that this route is cheaper, faster, more accurate or more private than another provider.
alternatives
The page names Amazon Bedrock and Google Cloud's Agent Platform as other Claude Code provider routes and says they offer interactive setup wizards. It supplies no comparison of their costs, model availability, performance or access requirements.
Within Foundry, the three authentication methods are practical alternatives: an API key copied from the portal, credentials resolved through the Azure SDK, or an Entra token supplied by another process. Claude Desktop users are directed to separate app-specific instructions rather than this CLI procedure.
evidence
The available evidence is the complete documentation page at [https://code.claude.com/docs/en/microsoft-foundry.md], captured on 25 November 2026 at 20:08:16.944 UTC. It contains configuration instructions, examples, warnings and troubleshooting advice.
The linked documentation index, model catalog, hosting guidance, Azure role documentation, pricing pages and Desktop guides are outside the supplied evidence. No installation, deployment, authentication attempt or model request was performed, and no benchmark or successful connection result is available.
Access & freshness
costs
Actual costs are unknown. The page provides no model token rates, subscription prices, spending examples, quotas or free-tier terms. It links to Microsoft Foundry pricing at [https://azure.microsoft.com/en-us/pricing/details/ai-foundry/], whose contents are outside the supplied evidence.
The explicit pricing distinction is that one-hour cache writes are billed at a higher rate than the five-minute default. Background tasks use the primary model by default unless an available Haiku deployment is configured, but the page gives no cost comparison or quantified savings.
rights
The captured page states no documentation license or permission to redistribute its text. Reuse rights are therefore unknown. It also does not establish the software license or service terms governing Claude Code and Microsoft Foundry.
freshness
The capture date establishes when this text was available; the page supplies no publication or last-updated date. Its model examples and default alias mappings remain time-sensitive and do not establish current availability in a particular account.
Before Claude Code v2.1.323, an unrecognized deployment name defaulted to a 200,000-token window; for such names, append [1m] if the deployed model supports one million tokens. Before v2.1.287, Fable models and Opus 4.7 and later also needed that suffix on Foundry to exceed the default 200,000-token window.
actions
Before configuring the CLI, confirm the subscription's Foundry access, required permissions, available model versions and deployment hosting option. Record exact deployment names, choose an authentication method and pin the models before distributing configuration to other users.
Check that authentication variables match the intended method, especially because a bearer token overrides an API key. Ensure custom deployment names have appropriate model mappings and that context limits match the deployed models. After configuration, use the documented /status check to inspect the provider and endpoint.
For the documented ChainedTokenCredential authentication failure, configure Entra credentials or supply an API key. For repeated connection errors on the first prompt, check that ANTHROPIC_FOUNDRY_RESOURCE contains the actual resource name rather than a placeholder. Confirm applicable prices and service terms separately because this page does not establish them.
