SpyBara
Go Premium

microsoft-foundry.md 2026-05-07 22:59 UTC to 2026-05-08 22:00 UTC

2 added, 112 removed.

2026
Sun 31 06:39 Sat 30 06:23 Fri 29 06:38 Thu 28 06:37 Wed 27 06:42 Tue 26 06:33 Sun 24 06:25 Sat 23 06:18 Fri 22 06:33 Thu 21 06:36 Wed 20 06:35 Tue 19 06:34 Mon 18 23:59 Sun 17 01:01 Fri 15 22:58 Thu 14 17:02 Wed 13 23:01 Tue 12 22:57 Mon 11 23:00 Sun 10 23:03 Sat 9 04:57 Fri 8 22:00 Thu 7 22:59 Tue 5 23:00 Mon 4 22:58 Sat 2 18:14 Fri 1 18:19

Microsoft Foundry 上的 Claude Code

了解如何透過 Microsoft Foundry 配置 Claude Code,包括設定、配置和故障排除。

export const ContactSalesCard = ({surface}) => { const utm = content => utm_source=claude_code&utm_medium=docs&utm_content=${surface}_${content}; const iconArrowRight = (size = 13) => <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"> ; const STYLES = .cc-cs { --cs-slate: #141413; --cs-clay: #d97757; --cs-clay-deep: #c6613f; --cs-gray-000: #ffffff; --cs-gray-700: #3d3d3a; --cs-border-default: rgba(31, 30, 29, 0.15); font-family: inherit; } .dark .cc-cs { --cs-slate: #f0eee6; --cs-gray-000: #262624; --cs-gray-700: #bfbdb4; --cs-border-default: rgba(240, 238, 230, 0.14); } .cc-cs-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 16px; margin: 0; background: var(--cs-gray-000); border: 0.5px solid var(--cs-border-default); border-radius: 8px; flex-wrap: wrap; } .cc-cs-text { font-size: 13px; color: var(--cs-gray-700); line-height: 1.5; flex: 1; min-width: 240px; } .cc-cs-text strong { font-weight: 550; color: var(--cs-slate); } .cc-cs-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; } .cc-cs-btn-clay { display: inline-flex; align-items: center; gap: 8px; background: var(--cs-clay-deep); color: #fff; border: none; border-radius: 8px; padding: 8px 14px; font-size: 13px; font-weight: 500; transition: background-color 0.15s; white-space: nowrap; } .cc-cs-btn-clay:hover { background: var(--cs-clay); } .cc-cs-btn-ghost { display: inline-flex; align-items: center; gap: 8px; background: transparent; color: var(--cs-gray-700); border: 0.5px solid var(--cs-border-default); border-radius: 8px; padding: 8px 14px; font-size: 13px; font-weight: 500; } .cc-cs-btn-ghost:hover { background: rgba(0, 0, 0, 0.04); } .dark .cc-cs-btn-ghost:hover { background: rgba(255, 255, 255, 0.04); } @media (max-width: 720px) { .cc-cs-actions { width: 100%; } }; return <div className="cc-cs not-prose"> <div className="cc-cs-card"> <div className="cc-cs-text"> Deploying Claude Code across your organization? Talk to sales about enterprise plans, SSO, and centralized billing.

<div className="cc-cs-actions"> <a href={https://claude.com/pricing?${utm('view_plans')}#plans-business} className="cc-cs-btn-ghost"> View plans <a href={https://claude.com/contact-sales?${utm('contact_sales')}} className="cc-cs-btn-clay"> Contact sales {iconArrowRight()}
; };

先決條件

在使用 Microsoft Foundry 配置 Claude Code 之前,請確保您具有:

設定

1. 佈建 Microsoft Foundry 資源

首先,在 Azure 中建立 Claude 資源:

  1. 瀏覽至 Microsoft Foundry 入口網站
  2. 建立新資源,並記下您的資源名稱
  3. 為 Claude 模型建立部署:
    • Claude Opus
    • Claude Sonnet
    • Claude Haiku

2. 配置 Azure 認證

Claude Code 支援 Microsoft Foundry 的兩種驗證方法。選擇最適合您安全性要求的方法。

選項 A:API 金鑰驗證

  1. 在 Microsoft Foundry 入口網站中瀏覽至您的資源
  2. 前往 端點和金鑰 部分
  3. 複製 API 金鑰
  4. 設定環境變數:
export ANTHROPIC_FOUNDRY_API_KEY=your-azure-api-key

選項 B:Microsoft Entra ID 驗證

當未設定 ANTHROPIC_FOUNDRY_API_KEY 時,Claude Code 會自動使用 Azure SDK 預設認證鏈。 這支援多種方法來驗證本機和遠端工作負載。

在本機環境中,您通常可以使用 Azure CLI:

az login

3. 配置 Claude Code

設定下列環境變數以啟用 Microsoft Foundry:

# 啟用 Microsoft Foundry 整合
export CLAUDE_CODE_USE_FOUNDRY=1

# Azure 資源名稱(將 {resource} 替換為您的資源名稱)
export ANTHROPIC_FOUNDRY_RESOURCE={resource}
# 或提供完整的基礎 URL:
# export ANTHROPIC_FOUNDRY_BASE_URL=https://{resource}.services.ai.azure.com/anthropic

4. 固定模型版本

設定模型變數以符合您在步驟 1 中建立的部署名稱。

如果沒有 ANTHROPIC_DEFAULT_OPUS_MODEL,Foundry 上的 opus 別名會解析為 Opus 4.6。將其設定為 Opus 4.7 ID 以使用最新模型:

export ANTHROPIC_DEFAULT_OPUS_MODEL='claude-opus-4-7'
export ANTHROPIC_DEFAULT_SONNET_MODEL='claude-sonnet-4-6'
export ANTHROPIC_DEFAULT_HAIKU_MODEL='claude-haiku-4-5'

如需目前和舊版模型 ID,請參閱模型概覽。如需完整的環境變數清單,請參閱模型配置

Prompt caching 會自動啟用。若要要求 1 小時的快取 TTL 而不是 5 分鐘的預設值,請設定下列變數;具有 1 小時 TTL 的快取寫入會以更高的費率計費:

export ENABLE_PROMPT_CACHING_1H=1

Azure RBAC 配置

Azure AI UserCognitive Services User 預設角色包含叫用 Claude 模型所需的所有權限。

如需更嚴格的權限,請建立具有以下內容的自訂角色:

{
  "permissions": [
    {
      "dataActions": [
        "Microsoft.CognitiveServices/accounts/providers/*"
      ]
    }
  ]
}

如需詳細資訊,請參閱 Microsoft Foundry RBAC 文件

故障排除

如果您收到錯誤「Failed to get token from azureADTokenProvider: ChainedTokenCredential authentication failed」:

其他資源