Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Build and deploy AI applications on Azure AI Foundry using Microsoft's model catalog and AI services
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
foundry-agent/create/references/sdk-operations.md
1# SDK Operations for Foundry Agent Service23Use the Foundry MCP tools for agent CRUD operations. When MCP tools are unavailable, use the `azure-ai-projects` Python SDK or REST API.45## Agent Operations via MCP67| Operation | MCP Tool | Description |8|-----------|----------|-------------|9| Create/Update agent | `agent_update` | Create a new agent or update an existing one (creates new version) |10| List/Get agents | `agent_get` | List all agents, or get a specific agent by name |11| Delete agent | `agent_delete` | Delete an agent |12| Invoke agent | `agent_invoke` | Send a message to an agent and get a response |13| Get schema | `agent_definition_schema_get` | Get the full JSON schema for agent definitions |1415## SDK Agent Operations1617When MCP tools are unavailable, use the `azure-ai-projects` Python SDK (`pip install azure-ai-projects --pre`):1819```python20from azure.ai.projects import AIProjectClient21from azure.identity import DefaultAzureCredential2223endpoint = "https://<resource>.services.ai.azure.com/api/projects/<project>"24client = AIProjectClient(endpoint=endpoint, credential=DefaultAzureCredential())25```2627| Operation | SDK Method |28|-----------|------------|29| Create | `client.agents.create_version(agent_name, definition)` |30| List | `client.agents.list()` |31| Get | `client.agents.get(agent_name)` |32| Update | `client.agents.create_version(agent_name, definition)` (creates new version) |33| Delete | `client.agents.delete(agent_name)` |34| Chat | `client.get_openai_client().responses.create(model=<deployment>, input=<text>, extra_body={"agent": {"name": agent_name, "type": "agent_reference"}})` |3536## Environment Variables3738| Variable | Description |39|----------|-------------|40| `PROJECT_ENDPOINT` | Foundry project endpoint (`https://<resource>.services.ai.azure.com/api/projects/<project>`) |41| `MODEL_DEPLOYMENT_NAME` | Deployed model name (e.g., `gpt-4.1-mini`) |4243## References4445- [Agent quickstart](https://learn.microsoft.com/azure/ai-foundry/agents/quickstart?view=foundry)46- [Create agents](https://learn.microsoft.com/azure/ai-foundry/agents/how-to/create-agent?view=foundry)47- [Tool Catalog](https://learn.microsoft.com/azure/ai-foundry/agents/concepts/tool-catalog?view=foundry)48