[BUG] [BUG] Claude not respecting Azure AI foundry environment variables
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?
After setting the environment variables for usage of AzureAI Foundry Claude model deployments as described in claude docs, claude continues to ask for user to login to an Anthropic account.
Setting the following environment variables:
export ANTHROPIC_FOUNDRY_API_KEY="my-key"
export CLAUDE_CODE_USE_FOUNDRY=1
export ANTHROPIC_FOUNDRY_BASE_URL="https://my-resource.services.ai.azure.com"
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"
curl commands to the same model endpoints are working successfully
What Should Happen?
Claude should launch and use the ai foundry model endpoints
Error Messages/Logs
Steps to Reproduce
Deploy claude modes in azure
Set environment variables
Launch claude
Claude Model
Not sure / Multiple models
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.0.42
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
18 Comments
Found 2 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
These are not duplicates. This issue is directly related to the documented process for Claudecode and azure ai foundry as noted here:
https://code.claude.com/docs/en/azure-ai-foundry
Same probleme here !
I think the article went out before launching an update for claude code to support azure ai foundry...
Possibly. I think the change notes indicate the feature was added
Hi i managed to make it work.
First I have added the variables export ANTHROPIC_DEFAULT_HAIKU_MODEL='claude-haiku-4-5'
export ANTHROPIC_DEFAULT_OPUS_MODEL='claude-opus-4-1' even if iam only using sonnet.
Then for the URL i used https://{myressource}-{location}.cognitiveservices.azure.com/anthropic you can find this URL on the page where you deployed claude it is in the python sample on the right.
Hope It will work for you
I tried a lot of combinations but I couldn't get it to work even with those directions. :-( Hoping for some other confirmation if others got it working.
Just saw an update in VSCode and refreshed tool and it worked for me now.
2.0.37.Also I set
CLAUDE_CODE_SKIP_AUTH_LOGIN=1per docs (didn't do trial and error to confirm if that was required, just happy to get it running :-) )Here's what I tested locally
I'm still running into issues in Azure Pipelines, but not certain of why it's hanging right now. Locally it worked.
Making progress here as well! The only issue I'm seeing now is that I don't get the haiku model as an option using the /model command.
Did you try claude-haiku-4-5? Not sure if they show up in models list without being set as env vars.
I still can't get it to work in CI and connect but did work locally.
FYI support for Microsoft Foundry was added in Claude Code version 2.0.45 (see https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md#2045). Once you set the appropriate env vars, you should see
claude /statusshowing the appropriate API Provider.@ant-kurt I've been trying for two days and no luck in a CI context when setting these. I've gotten it to run locally but nothing remote. Just timeouts. Any idea to force more debug logging so I can figure out if a new issue or same as this one?
Same issue, the .claude/settings.json is ignored and I only see the login screen of Claude Code.
@sheldonhull
ANTHROPIC_LOG=debug claude --debugwill enable request and debug logging - these logs go to a file whose path Claude Code will output on start. These will confirm if requests are going to the proper Foundry deployment with correct auth.@benyrfg please check that you're on Claude Code >= 2.0.45, the
/statuscommand shows the settings source (and no warnings about invalid settings files), and the env vars in settings.json are set like this:My version is 2.0.53, my env settings is:
The connection works in terminal, but not in the IDE (I see only login screen)
Can you try this?
Also, please make sure you're on the latest version of the VSCode extension (update it, and then restart VSCode). It should be v2.0.53 or higher
Thank you @hackyon-anthropic , The IDE is now displayed and connection works!
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.