К основному содержанию
скилл

azure-ai-projects-py — скилл для Claude Code: как установить

Скилл учит агента работать с Python SDK для Microsoft Foundry. Помогает создавать агентов, подключать инструменты и управлять подключениями к облаку.

Установить в Claude Code · Через Skills CLI (Vercel) Все способы и платформы ↓
npx skills add microsoft/skills --skill azure-ai-projects-py -a claude-code
Открыть на GitHub

Что делает azure-ai-projects-py

Скилл содержит готовые паттерны для высокоуровневого пакета azure-ai-projects. С ним ассистент генерирует код на Python для создания версионированных агентов через PromptAgentDefinition, управления тредами, запусками и датасетами.

В материалах описаны два сценария: вызов нативного AIProjectClient и подключение через OpenAI-совместимый клиент. Скилл требует обязательно оборачивать клиенты в контекстные менеджеры для освобождения сокетов и отдавать предпочтение DefaultAzureCredential вместо явных API-ключей.

Для запуска кода требуются библиотеки azure-ai-projects и azure-identity, а также переменные AZURE_AI_PROJECT_ENDPOINT и AZURE_AI_MODEL_DEPLOYMENT_NAME. Если требуются низкоуровневые операции с агентами, Microsoft рекомендует переключиться на скилл azure-ai-agents-python.

Какие задачи решает

  • инициализировать AIProjectClient с аутентификацией через DefaultAzureCredential
  • создать версионированного агента с помощью PromptAgentDefinition
  • подключить инструменты CodeInterpreterTool, AzureAISearchTool или McpTool
  • получить OpenAI-совместимый клиент из проекта Azure AI

Примеры запросов агенту

  • Напиши код создания агента с PromptAgentDefinition и поиском через FileSearchTool
  • Покажи, как инициализировать AIProjectClient и получить список доступных деплоев моделей
  • Настрой тред и запуск агента с помощью библиотеки azure-ai-projects

Как установить azure-ai-projects-py

1Через Skills CLI (Vercel)

npx skills add microsoft/skills --skill azure-ai-projects-py -a claude-code

2Вручную: положить файлы

~/.claude/skills/azure-ai-projects-py/SKILL.md

Папка скилла целиком; для одного проекта — .claude/skills/azure-ai-projects-py/

По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов

Вопросы о azure-ai-projects-py

Как установить azure-ai-projects-py в Claude Code?

Выполните команду npx skills add microsoft/skills --skill azure-ai-projects-py -a claude-code. Также можно вручную сохранить файл по пути ~/.claude/skills/azure-ai-projects-py/SKILL.md.

Что делает скилл azure-ai-projects-py?

Он предоставляет инструкции по использованию Python SDK для Azure AI Projects в Microsoft Foundry. Агент применяет эти правила при написании кода для агентов, инструментов и деплоев.

Какие переменные окружения нужны для работы SDK?

Обязательны AZURE_AI_PROJECT_ENDPOINT с адресом ресурса и AZURE_AI_MODEL_DEPLOYMENT_NAME с именем модели. Для продакшена через DefaultAzureCredential задают AZURE_TOKEN_CREDENTIALS=prod.

Исходный текст

SKILL.md · MIT
---
name: azure-ai-projects-py
description: Build AI applications using the Azure AI Projects Python SDK (azure-ai-projects). Use when working with Foundry project clients, creating versioned agents with PromptAgentDefinition, running evaluations, managing connections/deployments/datasets/indexes, or using OpenAI-compatible clients. This is the high-level Foundry SDK - for low-level agent operations, use azure-ai-agents-python skill.
license: MIT
metadata:
  author: Microsoft
  version: "1.0.0"
  package: azure-ai-projects
---

# Azure AI Projects Python SDK (Foundry SDK)

Build AI applications on Microsoft Foundry using the `azure-ai-projects` SDK.

## Installation

```bash
pip install azure-ai-projects azure-identity
```

## Environment Variables

```bash
AZURE_AI_PROJECT_ENDPOINT="https://<resource>.services.ai.azure.com/api/projects/<project>"  # Required for all auth methods
AZURE_AI_MODEL_DEPLOYMENT_NAME="gpt-4o-mini"  # Required for all auth methods
AZURE_TOKEN_CREDENTIALS=prod # Required only if DefaultAzureCredential is used in production
```

## Authentication & Lifecycle

> **🔑 Two rules apply to every code sample below:**
>
> 1. **Prefer `DefaultAzureCredential`.** It works locally (Azure CLI / VS Code / Developer CLI) and in Azure (managed identity, workload identity) with no code change. Avoid connection strings, account/API keys — they bypass Entra audit and rotation.
>    - Local dev: `DefaultAzureCredential` works as-is.
>    - Production: set `AZURE_TOKEN_CREDENTIALS=prod` (or `AZURE_TOKEN_CREDENTIALS=<specific_credential>`) to constrain the credential chain to production-safe credentials.
> 2. **Wrap every client in a context manager** so HTTP transports, sockets, and token caches are released deterministically:
>    - Sync: `with <Client>(...) as client:`
>    - Async: `async with <Client>(...) as client:` **and** `async with DefaultAzureCredential() as credential:` (from `azure.identity.aio`)
>
> Snippets may abbreviate this setup, but production code should always follow both rules.

```python
import os
from azure.identity import DefaultAzureCredential, ManagedIdentityCredential
from azure.ai.projects import AIProjectClient

# Local dev: DefaultAzureCredential. Production: set AZURE_TOKEN_CREDENTIALS=prod or AZURE_TOKEN_CREDENTIALS=<specific_credential>
credential = DefaultAzureCredential()
# Or use a specific credential directly in production:
# See https://learn.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#credential-classes
# credential = ManagedIdentityCredential()
with AIProjectClient(
    endpoint=os.environ["AZURE_AI_PROJECT_ENDPOINT"],
    credential=credential,
) as client:
    deployments = list(client.deployments.list())
```

## Client Operations Overview

| Operation | Access | Purpose |
|-----------|--------|---------|
| `client.agents` | `.agents.*` | Agent CRUD, versions, threads, runs |
| `client.connections` | `.connections.*` | List/get project connections |
| `client.deployments` | `.deployments.*` | List model deployments |
| `client.datasets` | `.datasets.*` | Dataset management |
| `client.indexes` | `.indexes.*` | Index management |
| `client.evaluations` | `.evaluations.*` | Run evaluations |
| `client.red_teams` | `.red_teams.*` | Red team operations |

## Two Client Approaches

### 1. AIProjectClient (Native Foundry)

```python
from azure.ai.projects import AIProjectClient

with AIProjectClient(
    endpoint=os.environ["AZURE_AI_PROJECT_ENDPOINT"],
    credential=DefaultAzureCredential(),
) as client:
    # Use Foundry-native operations
    agent = client.agents.create_agent(
        model=os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"],
        name="my-agent",
        instructions="You are helpful.",
    )
```

### 2. OpenAI-Compatible Client

```python
# Get OpenAI-compatible client from project
openai_client = client.get_openai_client()

# Use standard OpenAI API
response = openai_client.chat.completions.create(
    model=os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"],
    messages=[{"role": "user", "content": "Hello!"}],
)
```

## Agent Operations

### Create Agent (Basic)

```python
agent = client.agents.create_agent(
    model=os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"],
    name="my-agent",
    instructions="You are a helpful assistant.",
)
```

### Create Agent with Tools

```python
from azure.ai.agents.models import CodeInterpreterTool, FileSearchTool

agent = client.agents.create_agent(
    model=os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"],
    name="tool-agent",
    instructions="You can execute code and search files.",
    tools=[CodeInterpreterTool(), FileSearchTool()],
)
```

### Versioned Agents with PromptAgentDefinition

```python
from azure.ai.projects.models import PromptAgentDefinition

# Create a versioned agent
agent_version = client.agents.create_version(
    agent_name="customer-support-agent",
    definition=PromptAgentDefinition(
        model=os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"],
        instructions="You are a customer support specialist.",
        tools=[],  # Add tools as needed
    ),
    version_label="v1.0",
)
```

See [references/agents.md](references/agents.md) for detailed agent patterns.

## Tools Overview

| Tool | Class | Use Case |
|------|-------|----------|
| Code Interpreter | `CodeInterpreterTool` | Execute Python, generate files |
| File Search | `FileSearchTool` | RAG over uploaded documents |
| Bing Grounding | `BingGroundingTool` | Web search (requires connection) |
| Azure AI Search | `AzureAISearchTool` | Search your indexes |
| Function Calling | `FunctionTool` | Call your Python functions |
| OpenAPI | `OpenApiTool` | Call REST APIs |
| MCP | `McpTool` | Model Context Protocol servers |
| Memory Search | `MemorySearchTool` | Search agent memory stores |
| SharePoint | `SharepointGroundingTool` | Search SharePoint content |

See [references/tools.md](references/tools.md) for all tool patterns.

## Thread and Message Flow

```python
# 1. Create thread
thread = client.agents.threads.create()

# 2. Add message
client.agents.messages.create(
    thread_id=thread.id,
    role="user",
    content="What's the weather like?",
)

# 3. Create and process run
run = client.agents.runs.create_and_process(
    thread_id=thread.id,
    agent_id=agent.id,
)

# 4. Get response
if run.status == "completed":
    messages = client.agents.messages.list(thread_id=thread.id)
    for msg in messages:
        if msg.role == "assistant":
            print(msg.content[0].text.value)
```

## Connections

```python
# List all connections
connections = client.connections.list()
for conn in connections:
    print(f"{conn.name}: {conn.connection_type}")

# Get specific connection
connection = client.connections.get(connection_name="my-search-connection")
```

See [references/connections.md](references/connections.md) for connection patterns.

## Deployments

```python
# List available model deployments
deployments = client.deployments.list()
for deployment in deployments:
    print(f"{deployment.name}: {deployment.model}")
```

See [references/deployments.md](references/deployments.md) for deployment patterns.

## Datasets and Indexes

```python
# List datasets
datasets = client.datasets.list()

# List indexes
indexes = client.indexes.list()
```

See [references/datasets-indexes.md](references/datasets-indexes.md) for data operations.

## Evaluation

```python
# Using OpenAI client for evals
openai_client = client.get_openai_client()

# Create evaluation with built-in evaluators
eval_run = openai_client.evals.runs.create(
    eval_id="my-eval",
    name="quality-check",
    data_source={
        "type": "custom",
        "item_references": [{"item_id": "test-1"}],
    },
    testing_criteria=[
        {"type": "fluency"},
        {"type": "task_adherence"},
    ],
)
```

See [references/evaluation.md](references/evaluation.md) for evaluation patterns.

## Async Client

```python
from azure.ai.projects.aio import AIProjectClient

async with AIProjectClient(
    endpoint=os.environ["AZURE_AI_PROJECT_ENDPOINT"],
    credential=DefaultAzureCredential(),
) as client:
    agent = await client.agents.create_agent(...)
    # ... async operations
```

See [references/async-patterns.md](references/async-patterns.md) for async patterns.

## Memory Stores

```python
# Create memory store for agent
memory_store = client.agents.create_memory_store(
    name="conversation-memory",
)

# Attach to agent for persistent memory
agent = client.agents.create_agent(
    model=os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"],
    name="memory-agent",
    tools=[MemorySearchTool()],
    tool_resources={"memory": {"store_ids": [memory_store.id]}},
)
```

## Best Practices

1. **Pick sync OR async and stay consistent.** Do not mix `azure.ai.projects` sync clients with `azure.ai.projects.aio` async clients in the same call path. Choose one mode per module.
2. **Always use context managers for clients and async credentials.** Wrap every client in `with AIProjectClient(...) as client:` (sync) or `async with AIProjectClient(...) as client:` (async). For async `DefaultAzureCredential` from `azure.identity.aio`, also use `async with credential:` so tokens and transports are cleaned up.
3. **Clean up agents** when done: `client.agents.delete_agent(agent.id)`
4. **Use `create_and_process`** for simple runs, **streaming** for real-time UX
5. **Use versioned agents** for production deployments
6. **Prefer connections** for external service integration (AI Search, Bing, etc.)

## SDK Comparison

| Feature | `azure-ai-projects` | `azure-ai-agents` |
|---------|---------------------|-------------------|
| Level | High-level (Foundry) | Low-level (Agents) |
| Client | `AIProjectClient` | `AgentsClient` |
| Versioning | `create_version()` | Not available |
| Connections | Yes | No |
| Deployments | Yes | No |
| Datasets/Indexes | Yes | No |
| Evaluation | Via OpenAI client | No |
| When to use | Full Foundry integration | Standalone agent apps |

## Reference Files

- [references/agents.md](references/agents.md): Agent operations with PromptAgentDefinition
- [references/tools.md](references/tools.md): All agent tools with examples
- [references/evaluation.md](references/evaluation.md): Evaluation operations overview
- [references/built-in-evaluators.md](references/built-in-evaluators.md): Complete built-in evaluator reference
- [references/custom-evaluators.md](references/custom-evaluators.md): Code and prompt-based evaluator patterns
- [references/connections.md](references/connections.md): Connection operations
- [references/deployments.md](references/deployments.md): Deployment enumeration
- [references/datasets-indexes.md](references/datasets-indexes.md): Dataset and index operations
- [references/async-patterns.md](references/async-patterns.md): Async client usage
- [references/api-reference.md](references/api-reference.md): Complete API reference for all 373 SDK exports (v2.0.0b4)
- [scripts/run_batch_evaluation.py](scripts/run_batch_evaluation.py): CLI tool for batch evaluations

© Microsoft · MIT · microsoft/skills

Похожие скиллы

Все скиллы по теме «Облака: AWS, Azure, GCP» →
caveman-manage JuliusBrussee Проверяет состояние и результаты экспериментов Caveman Cloud, предлагает одно действие или блокирует рискованный запрос. Нужен перед запуском, одобрением, отменой или откатом. CX Codex +1 104 200установок workers-best-practices cloudflare Скилл настраивает ИИ на проверку продакшен-кода Cloudflare Workers по актуальным правилам рантайма, типам Wrangler и антипаттернам. CX Codex +1 126 100установок cloudflare-email-service cloudflare Скилл для работы с Cloudflare Email Sending и Email Routing: помогает настроить отправку и приём писем в Workers. CX Codex +1 102 300установок firebase-basics официальный google Скилл настраивает Firebase CLI, помогает войти в аккаунт, создать или выбрать проект и скачать конфигурацию Android или iOS. CX Codex 14 100установок cloudflare-one cloudflare Помогает агенту проектировать, настраивать и разбирать развёртывания Cloudflare One Zero Trust и SASE. Пригодится, когда нужно спланировать Access, Gateway или туннели без похода в документацию вручную. CX Codex +1 93 100установок cloudflare-one-migrations cloudflare Помогает спланировать переход с VPN, SWG или SASE на Cloudflare One: сопоставляет политики, находит пробелы и расписывает порядок выката. CX Codex +1 89 500установок

Из того же набора232

Весь набор →
azure-microsoft-playwright-testing-ts Скилл для запуска тестов Playwright на облачных браузерах Azure Playwright Workspaces и публикации результатов в портале Azure. 3установок azure-storage-blob-py Скилл учит агента работать с Azure Blob Storage из Python: загрузка и скачивание блобов, контейнеры, SAS-токены. 3установок azure-keyvault-py Учит агента работать с Azure Key Vault через официальный SDK для Python. Помогает писать безопасный код для секретов и криптографических ключей. 3установок azure-identity-py Скилл помогает подключать Python-приложения к Azure через Microsoft Entra ID. Он пригодится для DefaultAzureCredential, managed identity и service principal. 3установок azure-identity-dotnet Подсказывает агенту, как подключить Azure SDK к Microsoft Entra ID: цепочка DefaultAzureCredential, управляемые удостоверения, сервисные принципалы. 3установок entra-app-registration Скилл проводит через регистрацию приложения в Microsoft Entra ID, настройку OAuth 2.0 и подключение MSAL. Пригодится для пользовательской или сервисной аутентификации. 2установок azure-resource-lookup Перечисляет и находит ресурсы Azure по подпискам и группам через Azure Resource Graph. Нужен, когда надо увидеть, что вообще развёрнуто. 2установок azure-prepare Готовит проект к деплою через Azure Developer CLI: пишет azure.yaml, инфраструктуру на Bicep или Terraform и Dockerfile. Нужен, когда вы уже выбрали azd. 2установок

Спонсоры проекта

Компании, которые помогают держать аналитику открытой