Having trouble setting up Claude (From Azure/Foundry) in VS Code

Bruno S M 0 Reputation points
2026-03-19T01:41:47.33+00:00

Claude Code + Azure AI Foundry End‑to‑End Troubleshooting & Handoff Summary Prepared for: Microsoft / Azure Support Prepared by: Bruno (Transport Modellers Alliance) Context: Integrating Anthropic Claude (Haiku 4.5) via Azure AI Foundry using Claude Code CLI on Windows VS Code.

Environment

OS: Windows 11 Shell: PowerShell Claude Code CLI: v2.1.78 Azure Service: Azure AI Foundry Authentication: Foundry Project API Key Model deployed: Claude Haiku 4.5 Foundry project endpoint: [Foundry Project Endpoint Removed]

Root Causes Identified

  1. Foundry Project Endpoints Are Not DNS‑Derivable Project names and resource names are not routable DNS subdomains. Attempts to infer endpoints such as:
[Foundry Project Endpoint Removed]

correctly return NXDOMAIN. Only the explicit project endpoint shown in the Azure portal is valid.

  1. Mutually Exclusive Foundry Configuration Modes Claude Code supports one of the following: ANTHROPIC_FOUNDRY_RESOURCE ANTHROPIC_FOUNDRY_BASE_URL Using both simultaneously causes failures. Because this integration used a project endpoint, the correct configuration was:
ANTHROPIC_FOUNDRY_BASE_URL=[FOUNDRY_BASE_URL_REMOVED]

  1. Model Deployment Name Ambiguity Multiple deployments shared the same name (claude-haiku-4-5) but mapped to different model families. Claude Code initially resolved the wrong deployment, causing timeouts and misleading errors. Resolution required manually selecting the correct Haiku deployment via /model.

Final Working Configuration

CLAUDE_CODE_USE_FOUNDRY=1
ANTHROPIC_FOUNDRY_BASE_URL=[FOUNDRY_BASE_URL_REMOVED]
ANTHROPIC_FOUNDRY_API_KEY=<rotated>
ANTHROPIC_DEFAULT_HAIKU_MODEL=claude-haiku-4-5

Outcome Claude Code successfully initialized the repository (/init) CLAUDE.md created Claude Haiku 4.5 consumable via Azure AI Foundry No firewall, DNS, quota, or OS-level changes required

Why This Matters Without explicit endpoint usage and unambiguous deployment naming, external tools can fail in non-obvious ways that appear to be infrastructure issues. Standardising Foundry endpoint usage and deployment naming is critical for reliable automation and CI/CD integrations.

End of documentNote: PII REDACTED

Foundry Tools
Foundry Tools

Formerly known as Azure AI Services or Azure Cognitive Services is a unified collection of prebuilt AI capabilities within the Microsoft Foundry platform


1 answer

Sort by: Most helpful
  1. Manas R Mohanty 17,270 Reputation points Moderator
    2026-04-02T02:46:29.67+00:00

    Hey Bruno S M,

    Good day. I will try to replicate the scenario with above context anyway.

    But sharing the observation on call would have saved some time.Re-emphasizing the pointers for your reference.

    Root Cause 1 — Foundry Project Endpoints Are Not DNS-Derivable

    Source: Deploy and use Claude models in Microsoft Foundry — Microsoft Learn

    The official docs make clear that valid endpoints follow a strict, explicit pattern — they cannot be inferred. To work with your deployed model, you need your base URL, which is of the form https://<resource name>.services.ai.azure.com/anthropic, and your target URI from your deployment details, which is of the form https://<resource name>.services.ai.azure.com/anthropic/v1/messages. Microsoft Learn

    Source: Configure Claude Code for Microsoft Foundry — Microsoft Learn

    The portal navigation path to retrieve the correct endpoint is also documented explicitly: To find your base URL from the Foundry portal, go to the home page of the Foundry portal, find the Project endpoint, and copy the part of the URL that comes before /api/projects/<your-project-name>. Your base URL is of the form https://<your-resource-name>.services.ai.azure.com. Microsoft Learn

    This confirms that endpoint derivation from a project or resource name is not supported — the URL must be copied directly from the portal.

    Root Cause 2 — Mutually Exclusive Foundry Configuration Modes

    Source: Configure Claude Code for Microsoft Foundry — Microsoft Learn

    The official variable table documents the two modes as alternatives, not complements: ANTHROPIC_FOUNDRY_RESOURCE sets your Foundry resource name and Claude Code constructs the endpoint URL as https://<resource-name>.services.ai.azure.com/anthropic. The alternative is ANTHROPIC_FOUNDRY_BASE_URL, which allows you to provide the full base URL directly. Microsoft Learn

    The configuration block in the same document shows them as commented alternatives:

    powershell

    # Azure resource name (replace <your-resource-name> with your resource name)
    $env:ANTHROPIC_FOUNDRY_RESOURCE = "<your-resource-name>"
    # Or provide the full base URL:
    # $env:ANTHROPIC_FOUNDRY_BASE_URL = "https://<your-resource-name>.services.ai.azure.com"
    

    The # Or makes the mutual exclusivity explicit — only one should be set at a time. Bruno's integration used a project endpoint, so ANTHROPIC_FOUNDRY_BASE_URL was the correct choice, with ANTHROPIC_FOUNDRY_RESOURCE left unset.

    Root Cause 3 — Model Deployment Name Ambiguity

    Source: Configure Claude Code for Microsoft Foundry — Microsoft Learn

    Microsoft's own documentation explicitly warns about this risk and mandates pinning: Pin specific model versions for every deployment. If you use model aliases (sonnet, opus, haiku) without pinning, Claude Code may attempt to use a newer model version that isn't available in your Foundry account, breaking existing users when Anthropic releases updates. When you create Azure deployments, select a specific model version rather than "auto-update to latest." Microsoft Learn

    The recommended deployment names per role are also documented: Claude Code uses different models for different tasks — the primary model is claude-sonnet-4-6 for general coding, the fast model is claude-haiku-4-5 for quick operations like file reads and small edits, and the extended thinking model is claude-opus-4-6 for complex reasoning tasks. Microsoft Learn

    Source: Deploy and use Claude models in Microsoft Foundry — Microsoft Learn

    Thank you.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.