Blog Post

Educator Developer Blog
4 MIN READ

How to Set Up Claude Code with Microsoft Foundry Models on macOS

suzarilshah's avatar
Feb 10, 2026

Introduction

Building with AI isn't just about picking a smart model. It is about where that model lives. I chose to route my Claude Code setup through Microsoft Foundry because I needed more than just a raw API. I wanted the reliability, compliance, and structured management that comes with Microsoft's ecosystem. When you are moving from a prototype to something real, having that level of infrastructure backing your calls makes a significant difference.

The challenge is that Foundry is designed for enterprise cloud environments, while my daily development work happens locally on a MacBook. Getting the two to communicate seamlessly involved navigating a maze of shell configurations and environment variables that weren't immediately obvious.

I wrote this guide to document the exact steps for bridging that gap. Here is how you can set up Claude Code to run locally on macOS while leveraging the stability of models deployed on Microsoft Foundry.

Requirements

Before we open the terminal, let's make sure you have the necessary accounts and environments ready. Since we are bridging a local CLI with an enterprise cloud setup, having these credentials handy now will save you time later.

  1. Azure Subscription with Microsoft Foundry Setup - This is the most critical piece. You need an active Azure subscription where the Microsoft Foundry environment is initialized. Ensure that you have deployed the Claude model you intend to use and that the deployment status is active. You will need the specific endpoint URL and the associated API keys from this deployment to configure the connection.
  2. An Anthropic User Account - Even though the compute is happening on Azure, the interface requires an Anthropic account. You will need this to authenticate your session and manage your user profile settings within the Claude Code ecosystem.
  3. Claude Code Client on macOS - We will be running the commands locally, so you need the Claude Code CLI installed on your MacBook. 

Step 1: Install Claude Code on macOS 

The recommended installation method is via Homebrew or Curl, which sets it up for terminal access ("OS level"). 

Option A: Homebrew (Recommended)

brew install --cask claude-code

Option B: Curl

curl -fsSL https://claude.ai/install.sh | bash

Verify Installation: Run claude --version. 

Step 2: Set Up Microsoft Foundry to deploy Claude model

Navigate to your Microsoft Foundry portal, and find the Claude model catalog, and deploy the selected Claude model.

[Microsoft Foundry > My Assets > Models + endpoints > + Deploy Model > Deploy Base model > Search for "Claude"]

In your Model Deployment dashboard, go to the deployed Claude Models and get the "Endpoints and keys". Store it somewhere safe, because we will need them to configure Claude Code later on.

Configure Environment Variables in MacOS terminal:

Now we need to tell your local Claude Code client to route requests through Microsoft Foundry instead of the default Anthropic endpoints. This is handled by setting specific environment variables that act as a bridge between your local machine and your Azure resources.

 

You could run these commands manually every time you open a terminal, but it is much more efficient to save them permanently in your shell profile. For most modern macOS users, this file is .zshrc.

 

Open your terminal and add the following lines to your profile, making sure to replace the placeholder text with your actual Azure credentials:

export CLAUDE_CODE_USE_FOUNDRY=1
export ANTHROPIC_FOUNDRY_API_KEY="your-azure-api-key"
export ANTHROPIC_FOUNDRY_RESOURCE="your-resource-name"
# Specify the deployment name for Opus
export CLAUDE_CODE_MODEL="your-opus-deployment-name"

 

Once you have added these variables, you need to reload your shell configuration for the changes to take effect. Run the source command below to update your current session, and then verify the setup by launching Claude:

source ~/.zshrc
claude

 

If everything is configured correctly, the Claude CLI will initialize using your Microsoft Foundry deployment as the backend.

Once you execute the claude command, the CLI will prompt you to choose an authentication method. Select Option 2 (Antrophic Console account) to proceed.

This action triggers your default web browser and redirects you to the Claude Console. Simply sign in using your standard Anthropic account credentials.

 

After you have successfully signed in, you will be presented with a permissions screen. Click the Authorize button to link your web session back to your local terminal.

Return to your terminal window, and you should see a notification confirming that the login process is complete. Press Enter to finalize the setup.

 

You are now fully connected. You can start using Claude Code locally, powered entirely by the model deployment running in your Microsoft Foundry environment.

Conclusion

Setting up this environment might seem like a heavy lift just to run a CLI tool, but the payoff is significant. You now have a workflow that combines the immediate feedback of local development with the security and infrastructure benefits of Microsoft Foundry.

One of the most practical upgrades is the removal of standard usage caps. You are no longer limited to the 5-hour API call limits, which gives you the freedom to iterate, test, and debug for as long as your project requires without hitting a wall.

By bridging your local macOS terminal to Azure, you are no longer just hitting an API endpoint. You are leveraging a managed, compliance-ready environment that scales with your needs. The best part is that now the configuration is locked in, you don't need to think about the plumbing again.

You can focus entirely on coding, knowing that the reliability of an enterprise platform is running quietly in the background supporting every command.

Updated Jan 23, 2026
Version 1.0
No CommentsBe the first to comment