Microsoft Foundry SDK for Python 2
Last reviewed Oct 25, 2026
Prompt Details
Prompt Composition
2prompts
- Python 3155 lines · 3.8K tokens
- Microsoft Foundry SDK for Python 251 lines · 2.8K tokens
Total206 lines · 6.6K tokens
CWE Coverage
- 20
- 23
- 36
- 59
- 78
- 79
- 89
- 94
- 95
- 117
- 201
- 208
- 209
- 214
- 250
- 295
- 319
- 328
- 338
- 347
- 367
- 379
- 409
- 416
- 426
- 427
- 470
- 488
- 502
- 522
- 532
- 611
- 639
- 674
- 732
- 770
- 772
- 776
- 799
- 807
- 829
- 862
- 916
- 918
- 922
- 1104
- 1333
- 1395
- 1426
- 1427
Prompt Preview
Apply to azure-ai-projects 2.x and its AIProjectClient integration with Foundry agents and the OpenAI client. Check API availability against the installed minor; stable packages also expose preview features. Gate allow_preview=True and .beta use explicitly; .beta sub-clients do not require that flag. Apply the included Python baseline.
Identity and project boundaries
- Construct
AIProjectClient(endpoint=..., credential=...)from trusted deployment configuration. Allowlist the HTTPS project endpoint, deployment and agent names; never let request content redirect an authenticated client to another account or project. - Use an explicit production workload identity with narrowly scoped Entra roles. In deployed code pass
ManagedIdentityCredentialorWorkloadIdentityCredentialrather than a bareDefaultAzureCredential, whose chain can pick up host environment variables or developer sign-ins; if you keep the chain, setAZURE_TOKEN_CREDENTIALStoprodor one credential name withrequire_envvar=True. Don't call Foundry with account keys, because key authentication bypasses role restrictions. Separate principals that create or publish agents from those that only invoke them; assign Foundry Agent Consumer at agent scope for endpoint-only access, since project scope reaches every agent endpoint in the project. - Authorize the current application user before reading, updating, invoking or deleting agents, conversations, responses, files, datasets and connections. Bind IDs, including
previous_response_id, to the current tenant and user in server-side