Deploy Anthropic Claude on Microsoft Foundry with `azd up` (Bicep or Terraform) and call it with the official Claude SDKs over Entra ID.
概要
Then call it from the Anthropic SDK and the Claude Code CLI over Microsoft Entra ID — no API keys. Ships in both and . Works in the cloud (GitHub Codespaces) or on your laptop. By running azd up you accept Anthropic's commercial terms for Claude. Three short attestation fields (CLAUDE_ORGANIZATION_NAME, CLAUDE_COUNTRY_CODE, CLAUDE_INDUSTRY) are sent to Anthropic with every request and must match your real organization. Important — please read: Terms of use The Terraform and Bicep in this template both send a modelProviderData block (organizationName, countryCode, industry) with each Claude deployment. The Cognitive Services RP uses that block to — no manual click-through. Before deploying, please: 1. Read the legal docs that govern your use of Claude via Microsoft Foundry: - Anthropic Commercial Terms of Service — the master agreement for business / enterprise use (Foundry requires an Enterprise or MCA-E subscription).
README
The Claude on Foundry Starter Kit
Short link: ****
Deploy Claude (haiku, sonnet, opus) on Microsoft Foundry in one command. Then call it from the Anthropic SDK and the Claude Code CLI over Microsoft Entra ID — no API keys.
Ships in both Bicep and Terraform. Works in the cloud (GitHub Codespaces) or on your laptop.
[!IMPORTANT] By running
azd upyou accept Anthropic’s commercial terms for Claude. Three short attestation fields (CLAUDE_ORGANIZATION_NAME,CLAUDE_COUNTRY_CODE,CLAUDE_INDUSTRY) are sent to Anthropic with every request and must match your real organization. Read the Terms of use before you deploy.
Quickstart
The main path is azd up on your laptop. Two collapsed alternatives below if you’d rather run in the browser or have an AI agent drive it for you.
Local with azd up
You need:
- An Azure subscription eligible to deploy Claude in Foundry, with
Contributoron the target subscription/resource group (see Required permissions for the full breakdown, including the data-plane role you need to call the model). - Region:
eastus2orswedencentralhost all three Claude families (haiku / sonnet / opus).westus2is sonnet + opus only. - Tools: Azure CLI, azd, Python ≥ 3.10, and Terraform ≥ 1.6 (Terraform variant only).
- Run
az loginonce (in addition toazd auth login). Thepreprovisionhook usesazto validate that each requested Claude SKU exists in the Anthropic-on-Foundry catalog and that you have enough TPM quota in the chosen region. Ifazisn’t installed or signed in, the hook warns and skips those checks soazd upstill works — you just lose the proactive error messages.
git clone https://github.com/Azure-Samples/claude.git
cd claude/infra-bicep # or: cd claude/infra-terraform
# If your Claude-eligible subscription lives in a non-default tenant, pass --tenant-id:
azd auth login # or: azd auth login --tenant-id
azd env new my-claude
azd env set CLAUDE_ORGANIZATION_NAME "Contoso"
azd env set AZURE_LOCATION "swedencentral"
azd env set CLAUDE_SONNET_MODEL "claude-sonnet-4-6"
azd up
That’s it. To deploy other families, tweak capacity, or change attestation, see Choosing which models to deploy and All configuration variables in Advanced.
Use Claude
Python SDK
The Python sample is the primary hello-world path. It calls your Foundry-hosted Claude deployment with Microsoft Entra ID — no API key.
# from infra-bicep/ or infra-terraform/ (so `azd env get-values` works).
# Use Out-File so the file is UTF-8 (Windows PowerShell 5.1's `>` writes UTF-16, which python-dotenv mis-parses).
azd env get-values | Out-File -Encoding utf8 ..\.env.local
# macOS/Linux: azd env get-values > ../.env.local
cd ..
python -m venv .venv && . .venv/Scripts/Activate.ps1 # macOS/Linux: source .venv/bin/activate
pip install -r requirements.txt
python src/hello_claude.py # one-shot Messages call (Entra ID)
python src/chat_stream.py # interactive streaming chat — type a message, `exit` to quit
python src/hello_claude_token_refresh.py # long-running variant with per-request token refresh
Verify the wiring
One command runs every config check plus a live claude -p round trip per deployed family:
pwsh -File scripts/verify-claude-code.ps1
# macOS/Linux: bash scripts/verify-claude-code.sh
Exits non-zero on any failure — safe to wire into CI. Use -SkipClaudeCall for config-only checks (no token cost), or -RunPythonSample to also run the Python Entra ID round trip. For the manual breakdown of what the script does, see Verify Claude Code is wired up — manual checks in Advanced.
Advanced
Everything below is opt-in. The quickstart above is enough to get a working Claude deployment.
References
- Use Claude models in Microsoft Foundry
- Claude SDK (Python)
- Claude Messages API
- azd Terraform support
Contributing
Issues and PRs welcome. Please open an issue describing the change before sending large PRs.
License
推奨ツール
別のキーワードを試すか、フィルタを外してください。
インストール
npx skillfish add azure-samples/claude