Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,15 @@ CLAUDE_MODEL_CAPACITY=25
# CLAUDE_BASE_URL=https://<resource>.services.ai.azure.com/anthropic
# CLAUDE_DEPLOYMENT_NAME=claude-sonnet-4-6-abc123
# AZURE_TENANT_ID=<tenant-id> # Optional: scope SDK token requests to the deployment tenant.

# Portable SDK samples (process env; Python also loads gitignored .env.local).
# Canonical endpoint/model/key form one profile; do not mix it with CLAUDE_* keys.
# ANTHROPIC_BASE_URL=https://<resource>.services.ai.azure.com/anthropic
# ANTHROPIC_MODEL=<deployment-name>
# AUTH_MODE=bearer # Required explicitly with ANTHROPIC_BASE_URL.
# AZURE_TOKEN_CREDENTIALS=AzureCliCredential
# TOKEN_SCOPE=https://ai.azure.com/.default
# API-key authentication defaults to Authorization: Bearer and preserves SDK API version.
# Optional legacy overrides: ANTHROPIC_API_VERSION=2023-06-01, API_KEY_HEADER=x-api-key.
# Native provider: AUTH_MODE=api_key, ANTHROPIC_BASE_URL=https://api.anthropic.com.
# Supply the native API key through a secret store or process environment.
3 changes: 2 additions & 1 deletion .github/agents/claude-on-foundry.agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ Summarize what was deployed or changed, the resulting endpoint, and any manual f
## Rules

- Follow the skill instructions precisely. Don't invent `azd` env vars, regions, or CLI flags.
- **Passwordless only.** Microsoft Entra ID via `DefaultAzureCredential` / `az login`. Never write `CLAUDE_API_KEY`, subscription IDs, tenant IDs, or tokens into any tracked file.
- **Standard SDK clients only.** Use generic client/authentication helpers returning ordinary SDK clients, not platform-specific client imports or SDK subclasses. Claude Code's built-in Foundry mode is separate.
- **Passwordless by default.** Select explicit Azure CLI, azd, or managed-identity credentials. Keys for native-provider/resource-key samples belong only in process env or secret storage. Never write real keys, subscription IDs, tenant IDs, or tokens into tracked files.
- **Confirm before destructive actions** (`azd down`, `az cognitiveservices account purge`, `az role assignment delete`, deleting `.azure-cli/`, editing `~/.claude/settings.json`). State exactly what will be deleted and get explicit user confirmation. Never pass `--no-prompt` to skip hooks.
- **Don't mix variants** in the same `azd env`. Use a separate env per Bicep / Terraform / region combination.
- **Industry must be lowercase.** `technology`, `finance`, `healthcare`, `education`, `retail`, `manufacturing`, `government`, `media`, `other`.
Expand Down
2 changes: 2 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ This is the **Claude on Foundry Starter Kit** ([`Azure-Samples/claude`](https://
| `CLAUDE_HAIKU_CAPACITY` / `CLAUDE_SONNET_CAPACITY` / `CLAUDE_OPUS_CAPACITY` | no | `25` | TPM ÷ 1000 per family |
| `CLAUDE_MODEL_NAME` | no | `claude-sonnet-4-6` | **Legacy** single-deployment fallback (only used when all three `CLAUDE_*_MODEL` are empty) |
| `AZURE_TENANT_ID` | no | credential default | SDK token-request tenant; real IDs belong only in process env or gitignored `.env.local` |
| `AZURE_TOKEN_CREDENTIALS` | SDK | `AzureCliCredential` | Explicit SDK credential selection; use `AzureDeveloperCliCredential` after azd login or `ManagedIdentityCredential` in hosted workloads |
| `ASSIGN_RBAC` | no | `false` | `true` grants `Cognitive Services User` (least-privilege inference role) on the Foundry account to `AZURE_PRINCIPAL_ID` |
| `CLAUDE_CODE_AUTO_INSTALL` | no | `false` | `true` installs the Claude Code CLI in the postprovision hook |
| `CLAUDE_WRITE_VSCODE_SETTINGS` | no | `false` | `true` opts in to having the postprovision hook write `.vscode/settings.json` for the [Anthropic Claude Code VS Code extension](https://marketplace.visualstudio.com/items?itemName=anthropic.claude-code). Default skips it &mdash; the CLI / SDK don't need workspace settings. |
Expand All @@ -51,6 +52,7 @@ Always set vars with `azd env set <VAR> <VALUE>` from inside the chosen variant
- **Never mix the Bicep and Terraform variants in one environment.** Each variant uses its own `azd env`. If the user wants to switch, run `azd env new <name>` in the other folder.
- **Don't suggest disabling RBAC propagation retries.** An intermittent `401 PermissionDenied` immediately after `azd up` with `ASSIGN_RBAC=true` is normal — wait 1-3 minutes.
- **Honor the user's region.** `eastus2` and `swedencentral` host all three families; `westus2` is sonnet + opus only. Don't silently change `AZURE_LOCATION`.
- **Use standard Anthropic clients.** The generic helpers in [`src/`](../src/) and [`samples/`](../samples/) accept renewable-token callbacks and return ordinary SDK clients. Do not reintroduce platform-specific client imports or SDK subclasses. Claude Code's separate built-in Foundry mode remains enabled.

## Style

Expand Down
83 changes: 83 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,89 @@ jobs:
- name: Run offline SDK, catalog, and preflight regression tests
run: python -m unittest discover -s tests -v

typescript:
name: TypeScript SDK sample
runs-on: ubuntu-latest
defaults:
run:
working-directory: samples/typescript
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6
with:
node-version: "24"
cache: npm
cache-dependency-path: samples/typescript/package-lock.json
- run: npm ci
- run: npm run build
- run: npm test

go:
name: Go SDK sample
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6
with:
go-version-file: samples/go/go.mod
cache-dependency-path: samples/go/go.sum
- run: go vet ./...
working-directory: samples/go
- run: go test ./...
working-directory: samples/go

dotnet:
name: C# SDK sample
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1 # v5
with:
dotnet-version: "8.0.x"
- run: dotnet test samples/dotnet/AnthropicStandardSdk.sln --configuration Release

java:
name: Java SDK sample
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5
with:
distribution: temurin
java-version: "21"
cache: maven
cache-dependency-path: samples/java/pom.xml
- run: mvn --batch-mode test
working-directory: samples/java

php:
name: PHP SDK sample
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # v2
with:
php-version: "8.4"
tools: composer:v2
coverage: none
- run: composer install --no-interaction --prefer-dist
working-directory: samples/php
- run: composer test
working-directory: samples/php

ruby:
name: Ruby SDK sample
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: ruby/setup-ruby@7f797815d8adceb1c412e7abefdd1ab4abc47a5f # v1
with:
ruby-version: "3.4"
bundler-cache: true
working-directory: samples/ruby
- run: bundle exec ruby test/run.rb
working-directory: samples/ruby

shell:
name: Shellcheck + PSScriptAnalyzer
runs-on: ubuntu-latest
Expand Down
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,11 @@ local-only/
# 'az login' / 'azd' done in this workspace never touch ~/.azure and
# never leak into other VS Code windows. Pure runtime state — do not commit.
.azure-cli/

# Language sample dependencies and build output
node_modules/
**/bin/
**/obj/
**/target/
**/vendor/
.bundle/
3 changes: 2 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ The always-on rules below are the same ones in [`.github/copilot-instructions.md
- **Configure via `azd env set <KEY> <VALUE>`** from inside the chosen variant folder. There is no `.env` file. See the env-var contract in [`.github/copilot-instructions.md`](.github/copilot-instructions.md).
- **`INDUSTRY` is required with no default**: `technology`, `finance`, `healthcare`, `education`, `retail`, `manufacturing`, `government`, `media`, `other` (lowercase, per the [official guide](https://learn.microsoft.com/azure/developer/ai/how-to/deploy-claude-foundry#configure-required-deployment-values)). The `preup` hook prompts once and saves it; existing `CLAUDE_INDUSTRY` values migrate without prompting.
- **Honor the user's region.** `eastus2` and `swedencentral` host all three families; `westus2` is sonnet + opus only. Don't silently change `AZURE_LOCATION`.
- **Passwordless only.** Microsoft Entra ID via `DefaultAzureCredential` / `az login`. Never write `CLAUDE_API_KEY`, subscription IDs, tenant IDs, or tokens into any tracked file. Real values live in env vars, the gitignored `.env.local`, or the gitignored `.azure-cli/` token cache.
- **Standard SDK clients only.** Use the generic client/authentication helpers in [`src/`](./src/) and [`samples/`](./samples/), not platform-specific SDK clients. Helpers return the standard client and accept renewable-token callbacks. Claude Code's built-in Foundry mode is separate.
- **Passwordless by default.** Select explicit Azure CLI, azd, or managed-identity credentials. Native-provider/resource-key samples must take keys only from process env or secret storage. Never write real keys, subscription IDs, tenant IDs, or tokens into any tracked file; gitignored `.env.local` and `.azure-cli/` hold local runtime state.
- **Confirm before destructive actions.** Always get explicit user OK before: `azd down`, `az cognitiveservices account purge`, `az role assignment delete`, deleting `.azure-cli/`, editing `~/.claude/settings.json`. Never pass `--no-prompt` to skip hooks.
- **Diagnose, don't guess.** When a deployment fails, identify the exact error fingerprint (`715-123420`, `InsufficientQuota`, `AnthropicOrganizationCreationException`, `403 Forbidden`, `401 PermissionDenied`) and follow the matching row in the skill's DIAGNOSE table.
- **Run the existing scripts.** Don't invent ad-hoc `az` commands when [`Get-ClaudeCatalog.ps1`](./Get-ClaudeCatalog.ps1), [`scripts/preflight-claude.ps1`](./scripts/preflight-claude.ps1), [`scripts/configure-claude-code.ps1`](./scripts/configure-claude-code.ps1), [`scripts/verify-claude-code.ps1`](./scripts/verify-claude-code.ps1), or [`src/check_claude_quota.py`](./src/check_claude_quota.py) already cover the case.
Expand Down
7 changes: 7 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ The tests use mock HTTP transports and a fake Azure CLI; no Azure login,
deployment, API keys, or model quota is needed. PowerShell 7 is required for
the catalog and preflight tests. The SDK 2.x tests use its `httpx2` transport.

The [language samples](samples/README.md) each document their own offline build
and test commands. CI runs all seven SDK paths without cloud credentials.
Keep helpers generic and return standard Anthropic clients; do not introduce
platform-specific clients, custom token caches, or SDK retry implementations.
Live tests use the existing `azd up` deployment in one selected IaC variant;
keep real endpoint/account values and results in gitignored local files.

## Trademark notice

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
Expand Down
Loading
Loading