[BUG] Claude Code Extension (VSCode) Cannot Authenticate with Azure AI Foundry

Resolved 💬 5 comments Opened Mar 6, 2026 by JohannesZiegmann Closed Apr 16, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Summary

Claude Code VS Code extension (v2.1.70) fails to authenticate when using Azure AI Foundry (Microsoft Foundry) endpoints, despite the Azure API working correctly.

Environment

  • Extension Version: 2.1.70
  • VS Code Version: Latest (darwin-arm64)
  • OS: macOS (Apple Silicon)
  • Azure AI Foundry: Model deployment with Claude Sonnet 4-6, Claude Opus 4-6, Claude Haiku 4-5

Actual Behavior

Extension consistently fails with authentication error:

Could not resolve authentication method. Expected either apiKey or authToken to be set. 
Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted

What Should Happen?

The extension should authenticate successfully with Azure AI Foundry using either:

  1. Environment variables (ANTHROPIC_API_KEY, ANTHROPIC_BASE_URL)
  2. Settings file configuration (apiKey, baseURL)
  3. Microsoft Foundry-specific variables (ANTHROPIC_FOUNDRY_*)

Error Messages/Logs

## Key Log Evidence

From extension logs:

2026-03-06T18:21:58.681Z [DEBUG] [API:request] Creating client, 
  ANTHROPIC_CUSTOM_HEADERS present: false, 
  has Authorization header: false

2026-03-06T18:21:58.685Z [ERROR] API error (attempt 1/11): 
  Could not resolve authentication method. Expected either apiKey or authToken to be set. 
  Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted


The extension's SDK validation (`cli.js:321:1013`) is rejecting the API call **before** it reaches Azure.

## Root Cause Analysis

The extension's bundled binary (`/$bunfs/root/src/entrypoints/cli.js`) contains header validation logic that:
1. Does not recognize environment variables from settings
2. Does not properly pass credentials to the Anthropic SDK client
3. Fails validation even when credentials are correctly configured

The log shows `has Authorization header: false`, indicating credentials never reach the SDK client constructor.

Steps to Reproduce

1. Azure AI Foundry Setup (Working)

Azure endpoint is confirmed working via cURL:

curl -X POST "https://YOUR-RESOURCE-NAME.services.ai.azure.com/anthropic/v1/messages" \
  -H "Authorization: Bearer YOUR_AZURE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-sonnet-4-6",
    "messages": [{"role": "user", "content": "Hello"}],
    "max_tokens": 100
  }'

✅ Returns 200 OK with valid response

2. Attempted Configurations (All Failed)

Configuration A: Environment Variables

~/.claude/settings.json:

{
  "$schema": "https://json.schemastore.org/claude-code-settings.json",
  "model": "claude-sonnet-4-6",
  "environmentVariables": {
    "ANTHROPIC_API_KEY": "YOUR_AZURE_API_KEY",
    "ANTHROPIC_BASE_URL": "https://YOUR-RESOURCE-NAME.services.ai.azure.com/anthropic/v1"
  }
}

❌ Result: Same authentication error

Configuration B: Direct Settings
{
  "apiKey": "YOUR_AZURE_API_KEY",
  "baseURL": "https://YOUR-RESOURCE-NAME.services.ai.azure.com/anthropic/v1",
  "model": "claude-sonnet-4-6"
}

❌ Result: Same authentication error

Configuration C: authToken (Bearer)
{
  "authToken": "YOUR_AZURE_API_KEY",
  "baseURL": "https://YOUR-RESOURCE-NAME.services.ai.azure.com/anthropic/v1",
  "model": "claude-sonnet-4-6"
}

❌ Result: Same authentication error

Configuration D: Microsoft Foundry Variables
{
  "environmentVariables": {
    "CLAUDE_CODE_USE_FOUNDRY": "1",
    "ANTHROPIC_FOUNDRY_RESOURCE": "aiservices-claude-code",
    "ANTHROPIC_FOUNDRY_API_KEY": "YOUR_AZURE_API_KEY",
    "ANTHROPIC_FOUNDRY_ENDPOINT": "https://YOUR-RESOURCE-NAME.services.ai.azure.com/anthropic/v1"
  }
}

❌ Result: Same authentication error

Claude Model

Not sure / Multiple models

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.68 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

VS Code integrated terminal

Additional Information

Suggested Fix

The extension should:

  1. Read ANTHROPIC_API_KEY and ANTHROPIC_BASE_URL from environmentVariables
  2. Pass these to the Anthropic SDK client properly
  3. Handle Azure's Bearer token authentication (not just X-Api-Key)
  4. Skip header validation when using custom baseURL

Additional Context

  • Python SDK works perfectly with same credentials
  • Anthropic SDK supports custom base URLs natively
  • Issue appears to be in extension's wrapper, not the SDK itself

Related Files

  • Extension: anthropic.claude-code-2.1.70-darwin-arm64
  • Failing validation: cli.js:321:1013 (bundled binary)

---

To reproduce: Deploy Claude models on Azure AI Foundry and attempt to configure Claude Code extension with the endpoint and API key.

View original on GitHub ↗

This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗