SpyBara
Go Premium

microsoft-foundry.md 2025-11-26 00:04 UTC to 2025-11-27 06:02 UTC

5 added, 0 removed.

2025
Thu 27 06:02 Wed 26 00:04 Tue 25 03:22 Mon 24 21:01 Fri 21 00:04 Thu 20 18:02 Wed 19 03:21 Tue 18 18:02 Mon 17 03:24 Sun 16 00:04 Fri 14 21:26 Thu 6 18:02 Tue 4 18:02 Mon 3 21:01 Sun 2 18:01 Sat 1 21:01

Claude Code on Microsoft Foundry

Learn about configuring Claude Code through Microsoft Foundry, including setup, configuration, and troubleshooting.

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)

Setup

1. Provision Microsoft Foundry resource

First, create a Claude resource in Azure:

  1. Navigate to the Microsoft Foundry portal
  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:
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. This supports a variety of methods for authenticating local and remote workloads.

On local environments, you commonly may use the Azure CLI:

az login

3. Configure Claude Code

Set the following environment variables to enable Microsoft Foundry. Note that your deployments' names are set as the model identifiers in Claude Code (may be optional if using suggested deployment names).

# 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

# Set models to your resource's deployment names
export ANTHROPIC_DEFAULT_SONNET_MODEL='claude-sonnet-4-5'
export ANTHROPIC_DEFAULT_HAIKU_MODEL='claude-haiku-4-5'
export ANTHROPIC_DEFAULT_OPUS_MODEL='claude-opus-4-1'

For more details on model configuration options, see Model configuration.

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.

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


To find navigation and other pages in this documentation, fetch the llms.txt file at: https://code.claude.com/docs/llms.txt