[BUG] Claude Code Extension (VSCode) Cannot Authenticate with Azure AI Foundry
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:
- Environment variables (
ANTHROPIC_API_KEY,ANTHROPIC_BASE_URL) - Settings file configuration (
apiKey,baseURL) - 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:
- Read
ANTHROPIC_API_KEYandANTHROPIC_BASE_URLfromenvironmentVariables - Pass these to the Anthropic SDK client properly
- Handle Azure's Bearer token authentication (not just X-Api-Key)
- 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.
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗