[BUG] [BUG] Claude not respecting Azure AI foundry environment variables

Resolved 💬 18 comments Opened Nov 19, 2025 by mduddyaiprojects-coder Closed Nov 21, 2025
💡 Likely answer: A maintainer (ant-kurt, collaborator) responded on this thread — see the highlighted reply below.

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_

View original on GitHub ↗

18 Comments

github-actions[bot] · 7 months ago

Found 2 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/8522
  2. https://github.com/anthropics/claude-code/issues/8500

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

mduddyaiprojects-coder · 7 months ago

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

KBERRADAAAA · 7 months ago

Same probleme here !

KBERRADAAAA · 7 months ago

I think the article went out before launching an update for claude code to support azure ai foundry...

mduddyaiprojects-coder · 7 months ago
I think the article went out before launching an update for codex code to support azure ai foundry...

Possibly. I think the change notes indicate the feature was added

KBERRADAAAA · 7 months ago

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

sheldonhull · 7 months ago

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.

sheldonhull · 7 months ago

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=1 per 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

npm install -g @anthropic-ai/claude-code
claude '/logout'
unset ANTHROPIC_FOUNDRY_BASE_URL ANTHROPIC_FOUNDRY_RESOURCE ANTHROPIC_FOUNDRY_API_KEY ANTHROPIC_API_KEY
export CLAUDE_CODE_USE_FOUNDRY=1
# NOTE: don't think this was required export CLAUDE_CODE_SKIP_FOUNDRY_AUTH=1
export ANTHROPIC_FOUNDRY_API_KEY="$(az cognitiveservices account keys list --name '' --resource-group '' --subscription '' --query key1 -o tsv)"
export ANTHROPIC_DEFAULT_HAIKU_MODEL=claude-haiku-4-5
export ANTHROPIC_DEFAULT_SONNET_MODEL=claude-sonnet-4-5
export ANTHROPIC_DEFAULT_OPUS_MODEL=claude-opus-4-1
export ANTHROPIC_FOUNDRY_RESOURCE=''
claude -p 'random haiku about what is in this projects readme'

I'm still running into issues in Azure Pipelines, but not certain of why it's hanging right now. Locally it worked.

mduddyaiprojects-coder · 7 months ago

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.

sheldonhull · 7 months ago
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.

ant-kurt collaborator · 7 months ago

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 /status showing the appropriate API Provider.

sheldonhull · 7 months ago

@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?

benyrfg · 7 months ago

Same issue, the .claude/settings.json is ignored and I only see the login screen of Claude Code.

ant-kurt collaborator · 7 months ago

@sheldonhull ANTHROPIC_LOG=debug claude --debug will 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 /status command shows the settings source (and no warnings about invalid settings files), and the env vars in settings.json are set like this:

  "env": {
    "CLAUDE_CODE_USE_FOUNDRY": "1",
    "ANTHROPIC_FOUNDRY_RESOURCE": "your-resource",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "your-opus-deployment",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "your-sonnet-deployment",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "your-haiku-deployment"
  },
benyrfg · 7 months ago

My version is 2.0.53, my env settings is:

{
  "env": {
    "CLAUDE_CODE_USE_FOUNDRY": "1",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-4-5",
    "ANTHROPIC_FOUNDRY_BASE_URL": "https://my.openai.azure.com/anthropic",
    "ANTHROPIC_FOUNDRY_API_KEY": "xxx"

  }
}

The connection works in terminal, but not in the IDE (I see only login screen)

hackyon-anthropic collaborator · 7 months ago

Can you try this?

  1. Open up "Preferences: Open User Settings" in VSCode command palette
  2. Search for "claudeCode"
  3. Toggle on "Disable Login Prompt"
  4. Restart VSCode and see if it works

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

benyrfg · 7 months ago

Thank you @hackyon-anthropic , The IDE is now displayed and connection works!

github-actions[bot] · 7 months ago

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.