1> ## Documentation Index
2> Fetch the complete documentation index at: https://code.claude.com/docs/llms.txt
3> Use this file to discover all available pages before exploring further.
4
5# Claude Code su Microsoft Foundry
6
7> Scopri come configurare Claude Code tramite Microsoft Foundry, inclusi setup, configurazione e risoluzione dei problemi.
8
9export const ContactSalesCard = ({surface}) => {
10 const utm = content => `utm_source=claude_code&utm_medium=docs&utm_content=${surface}_${content}`;
11 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">
12 <line x1="5" y1="12" x2="19" y2="12" />
13 <polyline points="12 5 19 12 12 19" />
14 </svg>;
15 const STYLES = `
16.cc-cs {
17 --cs-slate: #141413;
18 --cs-clay: #d97757;
19 --cs-clay-deep: #c6613f;
20 --cs-gray-000: #ffffff;
21 --cs-gray-700: #3d3d3a;
22 --cs-border-default: rgba(31, 30, 29, 0.15);
23 font-family: inherit;
24}
25.dark .cc-cs {
26 --cs-slate: #f0eee6;
27 --cs-gray-000: #262624;
28 --cs-gray-700: #bfbdb4;
29 --cs-border-default: rgba(240, 238, 230, 0.14);
30}
31.cc-cs-card {
32 display: flex; align-items: center; justify-content: space-between;
33 gap: 16px; padding: 14px 16px; margin: 0;
34 background: var(--cs-gray-000); border: 0.5px solid var(--cs-border-default);
35 border-radius: 8px; flex-wrap: wrap;
36}
37.cc-cs-text { font-size: 13px; color: var(--cs-gray-700); line-height: 1.5; flex: 1; min-width: 240px; }
38.cc-cs-text strong { font-weight: 550; color: var(--cs-slate); }
39.cc-cs-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
40.cc-cs-btn-clay {
41 display: inline-flex; align-items: center; gap: 8px;
42 background: var(--cs-clay-deep); color: #fff; border: none;
43 border-radius: 8px; padding: 8px 14px;
44 font-size: 13px; font-weight: 500;
45 transition: background-color 0.15s; white-space: nowrap;
46}
47.cc-cs-btn-clay:hover { background: var(--cs-clay); }
48.cc-cs-btn-ghost {
49 display: inline-flex; align-items: center; gap: 8px;
50 background: transparent; color: var(--cs-gray-700);
51 border: 0.5px solid var(--cs-border-default);
52 border-radius: 8px; padding: 8px 14px;
53 font-size: 13px; font-weight: 500;
54}
55.cc-cs-btn-ghost:hover { background: rgba(0, 0, 0, 0.04); }
56.dark .cc-cs-btn-ghost:hover { background: rgba(255, 255, 255, 0.04); }
57@media (max-width: 720px) {
58 .cc-cs-actions { width: 100%; }
59}
60`;
61 return <div className="cc-cs not-prose">
62 <style>{STYLES}</style>
63 <div className="cc-cs-card">
64 <div className="cc-cs-text">
65 <strong>Deploying Claude Code across your organization?</strong> Talk to sales about enterprise plans, SSO, and centralized billing.
66 </div>
67 <div className="cc-cs-actions">
68 <a href={`https://claude.com/pricing?${utm('view_plans')}#plans-business`} className="cc-cs-btn-ghost">
69 View plans
70 </a>
71 <a href={`https://claude.com/contact-sales?${utm('contact_sales')}`} className="cc-cs-btn-clay">
72 Contact sales {iconArrowRight()}
73 </a>
74 </div>
75 </div>
76 </div>;
77};
78
79export const Experiment = ({flag, treatment, children}) => {
80 const VID_KEY = 'exp_vid';
81 const CONSENT_COUNTRIES = new Set(['AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE', 'RE', 'GP', 'MQ', 'GF', 'YT', 'BL', 'MF', 'PM', 'WF', 'PF', 'NC', 'AW', 'CW', 'SX', 'FO', 'GL', 'AX', 'GB', 'UK', 'AI', 'BM', 'IO', 'VG', 'KY', 'FK', 'GI', 'MS', 'PN', 'SH', 'TC', 'GG', 'JE', 'IM', 'CA', 'BR', 'IN']);
82 const fnv1a = s => {
83 let h = 0x811c9dc5;
84 for (let i = 0; i < s.length; i++) {
85 h ^= s.charCodeAt(i);
86 h += (h << 1) + (h << 4) + (h << 7) + (h << 8) + (h << 24);
87 }
88 return h >>> 0;
89 };
90 const bucket = (seed, vid) => fnv1a(fnv1a(seed + vid) + '') % 10000 < 5000 ? 'control' : 'treatment';
91 const [decision] = useState(() => {
92 const params = new URLSearchParams(location.search);
93 const preBucketed = document.documentElement.dataset['gb_' + flag.replace(/-/g, '_')];
94 const force = params.get('gb-force');
95 if (force) {
96 for (const p of force.split(',')) {
97 const [k, v] = p.split(':');
98 if (k === flag) return {
99 variant: v || 'treatment',
100 track: false
101 };
102 }
103 }
104 if (navigator.globalPrivacyControl) {
105 return {
106 variant: 'control',
107 track: false
108 };
109 }
110 const prefsMatch = document.cookie.match(/(?:^|; )anthropic-consent-preferences=([^;]+)/);
111 if (prefsMatch) {
112 try {
113 if (JSON.parse(decodeURIComponent(prefsMatch[1])).analytics !== true) {
114 return {
115 variant: 'control',
116 track: false
117 };
118 }
119 } catch {
120 return {
121 variant: 'control',
122 track: false
123 };
124 }
125 } else {
126 const country = params.get('country')?.toUpperCase() || (document.cookie.match(/(?:^|; )cf_geo=([A-Z]{2})/) || [])[1];
127 if (!country || CONSENT_COUNTRIES.has(country)) {
128 return {
129 variant: 'control',
130 track: false
131 };
132 }
133 }
134 let vid;
135 try {
136 const ajsMatch = document.cookie.match(/(?:^|; )ajs_anonymous_id=([^;]+)/);
137 if (ajsMatch) {
138 vid = decodeURIComponent(ajsMatch[1]).replace(/^"|"$/g, '');
139 } else {
140 vid = localStorage.getItem(VID_KEY);
141 if (!vid) {
142 vid = crypto.randomUUID();
143 }
144 document.cookie = `ajs_anonymous_id=${vid}; domain=.claude.com; path=/; Secure; SameSite=Lax; max-age=31536000`;
145 }
146 try {
147 localStorage.setItem(VID_KEY, vid);
148 } catch {}
149 } catch {
150 return {
151 variant: 'control',
152 track: false
153 };
154 }
155 const variant = preBucketed === '1' ? 'treatment' : preBucketed === '0' ? 'control' : bucket(flag, vid);
156 return {
157 variant,
158 track: true,
159 vid
160 };
161 });
162 useEffect(() => {
163 if (!decision.track) return;
164 fetch('https://api.anthropic.com/api/event_logging/v2/batch', {
165 method: 'POST',
166 headers: {
167 'Content-Type': 'application/json',
168 'x-service-name': 'claude_code_docs'
169 },
170 body: JSON.stringify({
171 events: [{
172 event_type: 'GrowthbookExperimentEvent',
173 event_data: {
174 device_id: decision.vid,
175 anonymous_id: decision.vid,
176 timestamp: new Date().toISOString(),
177 experiment_id: flag,
178 variation_id: decision.variant === 'treatment' ? 1 : 0,
179 environment: 'production'
180 }
181 }]
182 }),
183 keepalive: true
184 }).catch(() => {});
185 }, []);
186 return decision.variant === 'treatment' ? treatment : children;
187};
188
189<Experiment flag="docs-contact-sales-cta" treatment={<ContactSalesCard surface="foundry" />} />
190
191## Prerequisiti
192
193Prima di configurare Claude Code con Microsoft Foundry, assicurati di avere:
194
195* Un abbonamento Azure con accesso a Microsoft Foundry
196* Autorizzazioni RBAC per creare risorse e distribuzioni di Microsoft Foundry
197* Azure CLI installato e configurato (facoltativo - necessario solo se non hai un altro meccanismo per ottenere le credenziali)
198
199<Note>
200 Se stai distribuendo Claude Code a più utenti, [fissa le versioni del tuo modello](#4-pin-model-versions) per evitare problemi quando Anthropic rilascia nuovi modelli.
201</Note>
202
203## Setup
204
205### 1. Provisioning della risorsa Microsoft Foundry
206
207Per prima cosa, crea una risorsa Claude in Azure:
208
2091. Accedi al [portale Microsoft Foundry](https://ai.azure.com/)
2102. Crea una nuova risorsa, annotando il nome della risorsa
2113. Crea distribuzioni per i modelli Claude:
212 * Claude Opus
213 * Claude Sonnet
214 * Claude Haiku
215
216### 2. Configurare le credenziali Azure
217
218Claude Code supporta due metodi di autenticazione per Microsoft Foundry. Scegli il metodo che meglio si adatta ai tuoi requisiti di sicurezza.
219
220**Opzione A: Autenticazione tramite chiave API**
221
2221. Accedi alla tua risorsa nel portale Microsoft Foundry
2232. Vai alla sezione **Endpoint e chiavi**
2243. Copia **Chiave API**
2254. Imposta la variabile di ambiente:
226
227```bash theme={null}
228export ANTHROPIC_FOUNDRY_API_KEY=your-azure-api-key
229```
230
231**Opzione B: Autenticazione Microsoft Entra ID**
232
233Quando `ANTHROPIC_FOUNDRY_API_KEY` non è impostato, Claude Code utilizza automaticamente la [catena di credenziali predefinita](https://learn.microsoft.com/en-us/azure/developer/javascript/sdk/authentication/credential-chains#defaultazurecredential-overview) di Azure SDK.
234Questo supporta una varietà di metodi per autenticare carichi di lavoro locali e remoti.
235
236Negli ambienti locali, puoi comunemente utilizzare Azure CLI:
237
238```bash theme={null}
239az login
240```
241
242<Note>
243 Quando si utilizza Microsoft Foundry, i comandi `/login` e `/logout` sono disabilitati poiché l'autenticazione viene gestita tramite le credenziali Azure.
244</Note>
245
246### 3. Configurare Claude Code
247
248Imposta le seguenti variabili di ambiente per abilitare Microsoft Foundry:
249
250```bash theme={null}
251# Abilita l'integrazione Microsoft Foundry
252export CLAUDE_CODE_USE_FOUNDRY=1
253
254# Nome della risorsa Azure (sostituisci {resource} con il nome della tua risorsa)
255export ANTHROPIC_FOUNDRY_RESOURCE={resource}
256# Oppure fornisci l'URL di base completo:
257# export ANTHROPIC_FOUNDRY_BASE_URL=https://{resource}.services.ai.azure.com/anthropic
258```
259
260### 4. Fissa le versioni del modello
261
262<Warning>
263 Fissa versioni specifiche del modello per ogni distribuzione. Se utilizzi alias di modello (`sonnet`, `opus`, `haiku`) senza fissare, Claude Code potrebbe tentare di utilizzare una versione di modello più recente che non è disponibile nel tuo account Foundry, interrompendo gli utenti esistenti quando Anthropic rilascia aggiornamenti. Quando crei distribuzioni Azure, seleziona una versione di modello specifica piuttosto che "aggiornamento automatico alla versione più recente".
264</Warning>
265
266Imposta le variabili del modello in modo che corrispondano ai nomi di distribuzione che hai creato nel passaggio 1.
267
268Senza `ANTHROPIC_DEFAULT_OPUS_MODEL`, l'alias `opus` su Foundry si risolve in Opus 4.6. Impostalo sull'ID di Opus 4.7 per utilizzare il modello più recente:
269
270```bash theme={null}
271export ANTHROPIC_DEFAULT_OPUS_MODEL='claude-opus-4-7'
272export ANTHROPIC_DEFAULT_SONNET_MODEL='claude-sonnet-4-6'
273export ANTHROPIC_DEFAULT_HAIKU_MODEL='claude-haiku-4-5'
274```
275
276Per gli ID dei modelli attuali e legacy, vedi [Panoramica dei modelli](https://platform.claude.com/docs/en/about-claude/models/overview). Vedi [Configurazione del modello](/it/model-config#pin-models-for-third-party-deployments) per l'elenco completo delle variabili di ambiente.
277
278[Prompt caching](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) è abilitato automaticamente. Per richiedere un TTL della cache di 1 ora invece del valore predefinito di 5 minuti, imposta la seguente variabile; le scritture della cache con un TTL di 1 ora vengono fatturate a una tariffa più elevata:
279
280```bash theme={null}
281export ENABLE_PROMPT_CACHING_1H=1
282```
283
284## Configurazione RBAC di Azure
285
286I ruoli predefiniti `Azure AI User` e `Cognitive Services User` includono tutte le autorizzazioni necessarie per invocare i modelli Claude.
287
288Per autorizzazioni più restrittive, crea un ruolo personalizzato con quanto segue:
289
290```json theme={null}
291{
292 "permissions": [
293 {
294 "dataActions": [
295 "Microsoft.CognitiveServices/accounts/providers/*"
296 ]
297 }
298 ]
299}
300```
301
302Per i dettagli, vedi [Documentazione RBAC di Microsoft Foundry](https://learn.microsoft.com/en-us/azure/ai-foundry/concepts/rbac-azure-ai-foundry).
303
304## Risoluzione dei problemi
305
306Se ricevi un errore "Failed to get token from azureADTokenProvider: ChainedTokenCredential authentication failed":
307
308* Configura Entra ID nell'ambiente, oppure imposta `ANTHROPIC_FOUNDRY_API_KEY`.
309
310## Risorse aggiuntive
311
312* [Documentazione di Microsoft Foundry](https://learn.microsoft.com/en-us/azure/ai-foundry/what-is-azure-ai-foundry)
313* [Modelli di Microsoft Foundry](https://ai.azure.com/explore/models)
314* [Prezzi di Microsoft Foundry](https://azure.microsoft.com/en-us/pricing/details/ai-foundry/)