Communityライティング&編集github.com

microsoft/azure-ai-projects-dotnet

Azure AI Projects SDK for .NET。Azure AI Foundryプロジェクトの高レベルクライアントで、エージェント、接続、データセット、デプロイ、評価、インデックスを提供します。AI Foundryプロジェクト管理、バージョン管理されたエージェント、オーケストレーションに使用します。トリガー:「AI Projects」「AIProjectClient」「Foundry project」「versioned agents」「evaluations」「datasets」「connections」「deployments .NET」。

azure-ai-projects-dotnet とは?

このスキルは、Azure AI Foundryプロジェクトの操作を.NETから行うための高レベルSDK「Azure.AI.Projects」を提供します。AIProjectClientを中心に、エージェント管理、接続管理、データセットのアップロード、モデルデプロイの確認、評価の実行、インデックスの作成といった主要なワークフローを統一的に扱えます。NuGetパッケージとしてインストールし、DefaultAzureCredentialによる認証が標準です。プレビュー版ではOpenAI拡張を使ったバージョン管理エージェントや、低レベル操作のためのPersistentAgentsClientも利用可能です。コード例を通じて、エージェントの作成・実行、ツール連携、エラーハンドリング、ベストプラクティスも学べます。

対応~Claude Code✓Codex CLI~Cursor
npx skills add https://github.com/microsoft/agent-skills/tree/main/.github/plugins/azure-sdk-dotnet/skills/azure-ai-projects-dotnet

Installed? Explore more ライティング&編集 skills: steipete/notion, langchain-ai/langchain, bytedance/podcast-generation · View all 6 →

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

Azure.AI.Projects (.NET)

Azure AI Foundryプロジェクト操作のための高レベルSDK。エージェント、接続、データセット、デプロイ、評価、インデックスを含みます。

インストール

dotnet add package Azure.AI.Projects
dotnet add package Azure.Identity

# オプション:OpenAI拡張を使用したバージョン管理エージェント用
dotnet add package Azure.AI.Projects.OpenAI --prerelease

# オプション:低レベルエージェント操作用
dotnet add package Azure.AI.Agents.Persistent --prerelease

現在のバージョン:GA v1.1.0、プレビュー v1.2.0-beta.5

環境変数

PROJECT_ENDPOINT=https://<resource>.services.ai.azure.com/api/projects/<project>  # 必須:Azure AIプロジェクトエンドポイント
MODEL_DEPLOYMENT_NAME=gpt-4o-mini  # 必須:モデルデプロイ名
CONNECTION_NAME=<your-connection-name>  # オプション:プロジェクト接続名
AI_SEARCH_CONNECTION_NAME=<ai-search-connection>  # オプション:Azure AI Search接続名
AZURE_TOKEN_CREDENTIALS=prod  # 本番環境でDefaultAzureCredentialを使用する場合のみ必須

認証

using Azure.Identity;
using Azure.AI.Projects;

var endpoint = Environment.GetEnvironmentVariable("PROJECT_ENDPOINT");
// ローカル開発:DefaultAzureCredential。本番環境:AZURE_TOKEN_CREDENTIALS=prod または AZURE_TOKEN_CREDENTIALS=<specific_credential> を設定
var credential = new DefaultAzureCredential(
    DefaultAzureCredential.DefaultEnvironmentVariableName
);
// または、本番環境では特定の資格情報を直接使用:
// https://learn.microsoft.com/dotnet/api/overview/azure/identity-readme?view=azure-dotnet#credential-classes を参照
// var credential = new ManagedIdentityCredential();
AIProjectClient projectClient = new AIProjectClient(
    new Uri(endpoint), 
    credential);

クライアント階層

AIProjectClient
├── Agents          → AIProjectAgentsOperations (バージョン管理エージェント)
├── Connections     → ConnectionsClient
├── Datasets        → DatasetsClient
├── Deployments     → DeploymentsClient
├── Evaluations     → EvaluationsClient
├── Evaluators      → EvaluatorsClient
├── Indexes         → IndexesClient
├── Telemetry       → AIProjectTelemetry
├── OpenAI          → ProjectOpenAIClient (プレビュー)
└── GetPersistentAgentsClient() → PersistentAgentsClient

コアワークフロー

1. 永続エージェントクライアントの取得

// プロジェクトクライアントから低レベルエージェントクライアントを取得
PersistentAgentsClient agentsClient = projectClient.GetPersistentAgentsClient();

// エージェントを作成
PersistentAgent agent = await agentsClient.Administration.CreateAgentAsync(
    model: "gpt-4o-mini",
    name: "Math Tutor",
    instructions: "あなたは個人向け数学チューターです。");

// スレッドと実行を作成
PersistentAgentThread thread = await agentsClient.Threads.CreateThreadAsync();
await agentsClient.Messages.CreateMessageAsync(thread.Id, MessageRole.User, "3x + 11 = 14 を解いてください");
ThreadRun run = await agentsClient.Runs.CreateRunAsync(thread.Id, agent.Id);

// 完了するまでポーリング
do
{
    await Task.Delay(500);
    run = await agentsClient.Runs.GetRunAsync(thread.Id, run.Id);
}
while (run.Status == RunStatus.Queued || run.Status == RunStatus.InProgress);

// メッセージを取得
await foreach (var msg in agentsClient.Messages.GetMessagesAsync(thread.Id))
{
    foreach (var content in msg.ContentItems)
    {
        if (content is MessageTextContent textContent)
            Console.WriteLine(textContent.Text);
    }
}

// クリーンアップ
await agentsClient.Threads.DeleteThreadAsync(thread.Id);
await agentsClient.Administration.DeleteAgentAsync(agent.Id);

2. ツールを使用したバージョン管理エージェント(プレビュー)

using Azure.AI.Projects.OpenAI;

// Web検索ツールを使用してエージェントを作成
PromptAgentDefinition agentDefinition = new(model: "gpt-4o-mini")
{
    Instructions = "あなたはWeb検索ができる便利なアシスタントです",
    Tools = {
        ResponseTool.CreateWebSearchTool(
            userLocation: WebSearchToolLocation.CreateApproximateLocation(
                country: "US",
                city: "Seattle",
                region: "Washington"
            )
        ),
    }
};

AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync(
    agentName: "myAgent",
    options: new(agentDefinition));

// レスポンスクライアントを取得
ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion.Name);

// レスポンスを作成
ResponseResult response = responseClient.CreateResponse("シアトルの天気は?");
Console.WriteLine(response.GetOutputText());

// クリーンアップ
projectClient.Agents.DeleteAgentVersion(agentName: agentVersion.Name, agentVersion: agentVersion.Version);

3. 接続

// すべての接続を一覧表示
foreach (AIProjectConnection connection in projectClient.Connections.GetConnections())
{
    Console.WriteLine($"{connection.Name}: {connection.ConnectionType}");
}

// 特定の接続を取得
AIProjectConnection conn = projectClient.Connections.GetConnection(
    connectionName, 
    includeCredentials: true);

// デフォルト接続を取得
AIProjectConnection defaultConn = projectClient.Connections.GetDefaultConnection(
    includeCredentials: false);

4. デプロイ

// すべてのデプロイを一覧表示
foreach (AIProjectDeployment deployment in projectClient.Deployments.GetDeployments())
{
    Console.WriteLine($"{deployment.Name}: {deployment.ModelName}");
}

// パブリッシャーでフィルタ
foreach (var deployment in projectClient.Deployments.GetDeployments(modelPublisher: "Microsoft"))
{
    Console.WriteLine(deployment.Name);
}

// 特定のデプロイを取得
ModelDeployment details = (ModelDeployment)projectClient.Deployments.GetDeployment("gpt-4o-mini");

5. データセット

// 単一ファイルをアップロード
FileDataset fileDataset = projectClient.Datasets.UploadFile(
    name: "my-dataset",
    version: "1.0",
    filePath: "data/training.txt",
    connectionName: connectionName);

// フォルダをアップロード
FolderDataset folderDataset = projectClient.Datasets.UploadFolder(
    name: "my-dataset",
    version: "2.0",
    folderPath: "data/training",
    connectionName: connectionName,
    filePattern: new Regex(".*\\.txt"));

// データセットを取得
AIProjectDataset dataset = projectClient.Datasets.GetDataset("my-dataset", "1.0");

// データセットを削除
projectClient.Datasets.Delete("my-dataset", "1.0");

6. インデックス

// Azure AI Searchインデックスを作成
AzureAISearchIndex searchIndex = new(aiSearchConnectionName, aiSearchIndexName)
{
    Description = "サンプルインデックス"
};

searchIndex = (AzureAISearchIndex)projectClient.Indexes.CreateOrUpdate(
    name: "my-index",
    version: "1.0",
    index: searchIndex);

// インデックスを一覧表示
foreach (AIProjectIndex index in projectClient.Indexes.GetIndexes())
{
    Console.WriteLine(index.Name);
}

// インデックスを削除
projectClient.Indexes.Delete(name: "my-index", version: "1.0");

7. 評価

// 評価設定を作成
var evaluatorConfig = new EvaluatorConfiguration(id: EvaluatorIDs.Relevance);
evaluatorConfig.InitParams.Add("deployment_name", BinaryData.FromObjectAsJson("gpt-4o"));

// 評価を作成
Evaluation evaluation = new Evaluation(
    data: new InputDataset("<dataset_id>"),
    evaluators: new Dictionary<string, EvaluatorConfiguration> 
    { 
        { "relevance", evaluatorConfig } 
    }
)
{
    DisplayName = "サンプル評価"
};

// 評価を実行
Evaluation result = projectClient.Evaluations.Create(evaluation: evaluation);

// 評価を取得
Evaluation getResult = projectClient.Evaluations.Get(result.Name);

// 評価を一覧表示
foreach (var eval in projectClient.Evaluations.GetAll())
{
    Console.WriteLine($"{eval.DisplayName}: {eval.Status}");
}

8. Azure OpenAI Chatクライアントの取得

using Azure.AI.OpenAI;
using OpenAI.Chat;

ClientConnection connection = projectClient.GetConnection(typeof(AzureOpenAIClient).FullName!);

if (!connection.TryGetLocatorAsUri(out Uri uri) || uri is null)
    throw new InvalidOperationException("無効なURIです。");

uri = new Uri($"https://{uri.Host}");

AzureOpenAIClient azureOpenAIClient = new AzureOpenAIClient(uri, new DefaultAzureCredential());
ChatClient chatClient = azureOpenAIClient.GetChatClient("gpt-4o-mini");

ChatCompletion result = chatClient.CompleteChat("虹の色をすべてリストアップしてください");
Console.WriteLine(result.Content[0].Text);

利用可能なエージェントツール

ツールクラス目的
Code InterpreterCodeInterpreterToolDefinitionPythonコードの実行
File SearchFileSearchToolDefinitionアップロードされたファイルの検索
Function CallingFunctionToolDefinitionカスタム関数の呼び出し
Bing GroundingBingGroundingToolDefinitionBingによるWeb検索
Azure AI SearchAzureAISearchToolDefinitionAzure AIインデックスの検索
OpenAPIOpenApiToolDefinition外部APIの呼び出し
Azure FunctionsAzureFunctionToolDefinitionAzure Functionsの呼び出し
MCPMCPToolDefinitionModel Context Protocolツール

主要型リファレンス

型目的
AIProjectClientメインエントリポイント
PersistentAgentsClient低レベルエージェント操作
PromptAgentDefinitionバージョン管理エージェント定義
AgentVersionバージョン管理エージェントインスタンス
AIProjectConnectionAzureリソースへの接続
AIProjectDeploymentモデルデプロイ情報
AIProjectDatasetデータセットメタデータ
AIProjectIndex検索インデックスメタデータ
Evaluation評価設定と結果

ベストプラクティス

  1. DefaultAzureCredentialを使用して本番認証を行う
  2. 非同期メソッド(*Async)をすべてのI/O操作に使用する
  3. 適切な遅延でポーリング(500ms推奨)して実行完了を待つ
  4. リソースをクリーンアップ — スレッド、エージェント、ファイルは使用後に削除
  5. バージョン管理エージェントを(Azure.AI.Projects.OpenAI経由で)本番シナリオに使用
  6. 接続IDを保存(名前ではなく)してツール設定に使用
  7. includeCredentials: true は資格情報が必要な場合のみ使用
  8. ページネーションを処理 — リスト操作にはAsyncPageable<T>を使用

エラーハンドリング

using Azure;

try
{
    var result = await projectClient.Evaluations.CreateAsync(evaluation);
}
catch (RequestFailedException ex)
{
    Console.WriteLine($"エラー: {ex.Status} - {ex.ErrorCode}: {ex.Message}");
}

関連SDK

SDK目的インストール
Azure.AI.Projects高レベルプロジェクトクライアント(本SDK)dotnet add package Azure.AI.Projects
Azure.AI.Agents.Persistent低レベルエージェント操作dotnet add package Azure.AI.Agents.Persistent
Azure.AI.Projects.OpenAIOpenAIを使用したバージョン管理エージェントdotnet add package Azure.AI.Projects.OpenAI

参考リンク

リソースURL
NuGetパッケージhttps://www.nuget.org/packages/Azure.AI.Projects
APIリファレンスhttps://learn.microsoft.com/dotnet/api/azure.ai.projects
GitHubソースhttps://github.com/Azure/azure-sdk-for-net/tree/main/sdk/ai/Azure.AI.Projects
サンプルhttps://github.com/Azure/azure-sdk-for-net/tree/main/sdk/ai/Azure.AI.Projects/samples

Individual skills in this repo

This repo contains 12 individual skills — each has its own dedicated page.

microsoft/azure-ai-agents-persistent-dotnet

Azure AI Agents Persistent SDK for .NET. Low-level SDK for creating and managing AI agents with threads, messages, runs, and tools. Use for agent CRUD, conversation threads, streaming responses, function calling, file search, and code interpreter. Triggers: "PersistentAgentsClient", "persistent agents", "agent threads", "agent runs", "streaming agents", "function calling agents .NET".

microsoft/azure-ai-document-intelligence-dotnet

Azure AI Document Intelligence SDK for .NET. Extract text, tables, and structured data from documents using prebuilt and custom models. Use for invoice processing, receipt extraction, ID document analysis, and custom document models. Triggers: "Document Intelligence", "DocumentIntelligenceClient", "form recognizer", "invoice extraction", "receipt OCR", "document analysis .NET".

microsoft/azure-ai-openai-dotnet

Azure OpenAI SDK for .NET. Client library for Azure OpenAI and OpenAI services. Use for chat completions, embeddings, image generation, audio transcription, and assistants. Triggers: "Azure OpenAI", "AzureOpenAIClient", "ChatClient", "chat completions .NET", "GPT-4", "embeddings", "DALL-E", "Whisper", "OpenAI .NET".

microsoft/azure-ai-voicelive-dotnet

Azure AI Voice Live SDK for .NET. Build real-time voice AI applications with bidirectional WebSocket communication. Use for voice assistants, conversational AI, real-time speech-to-speech, and voice-enabled chatbots. Triggers: "voice live", "real-time voice", "VoiceLiveClient", "VoiceLiveSession", "voice assistant .NET", "bidirectional audio", "speech-to-speech".

microsoft/azure-eventgrid-dotnet

Azure Event Grid SDK for .NET. Client library for publishing and consuming events with Azure Event Grid. Use for event-driven architectures, pub/sub messaging, CloudEvents, and EventGridEvents. Triggers: "Event Grid", "EventGridPublisherClient", "CloudEvent", "EventGridEvent", "publish events .NET", "event-driven", "pub/sub".

microsoft/azure-eventhub-dotnet

Azure Event Hubs SDK for .NET. Use for high-throughput event streaming: sending events (EventHubProducerClient, EventHubBufferedProducerClient), receiving events (EventProcessorClient with checkpointing), partition management, and real-time data ingestion. Triggers: "Event Hubs", "event streaming", "EventHubProducerClient", "EventProcessorClient", "send events", "receive events", "checkpointing", "partition".

microsoft/azure-identity-dotnet

Azure Identity library for .NET. Authentication library for Azure SDK clients using Microsoft Entra ID. Use for DefaultAzureCredential, managed identity, service principals, and developer credentials. Triggers: "Azure Identity", "DefaultAzureCredential", "ManagedIdentityCredential", "ClientSecretCredential", "authentication .NET", "Azure auth", "credential chain".

microsoft/azure-kusto-graph

Build and query Kusto graphs from natural language. Covers transient graphs (make-graph), persistent graph models/snapshots, pattern matching (graph-match), shortest paths, connected components, and graph-to-table export. Generates the edges-first thinking: define edges, define node lookups, union, make-graph. WHEN: make-graph, graph-match, graph-shortest-paths, graph-to-table, graph-mark-components, persistent graph, graph model, graph snapshot, build a graph from data, find paths between nodes, pattern matching in graph, connected components, transient graph, Kusto graph, KQL graph.

microsoft/azure-kusto-irql

Compose IRQL (Incident Response Query Language) queries for Kusto cybersecurity investigations. Translates natural language hunting questions into composable IRQL pipelines using Get_*, Extract_*, and Enrich_* functions. WHEN: IRQL query, security hunt, threat hunting KQL, incident response query, compose hunting pipeline, failed logins, phishing investigation, lateral movement, process execution, file creation events.

microsoft/azure-kusto-irql-graph

Apply IRQL graph functions to KQL or IRQL query results for Kusto Explorer visualization. Generates Lift_To_Graph mappings and composes Graph_Render_View, Graph_Fold_By_Property, Extract_Node_*, Enrich_Node_*, and Enrich_Graph_* calls. Accepts a supplied query or limited basic natural-language source request; it is not a general natural-language-to-KQL/IRQL skill. WHEN: Lift_To_Graph, Graph_Render_View, Graph_Fold_By_Property, IRQL graph enrichment, graph mapping for existing query results, icon-decorated graph, fold graph nodes. Use azure-kusto-graph for native make-graph analysis, graph-match, shortest paths, components, or persistent graphs.

microsoft/azure-local

Plan, deploy, operate, and troubleshoot Azure Local (formerly Azure Stack HCI): sizing and prerequisites, Arc registration, lifecycle updates, workloads (Azure Local VMs, AKS on Azure Local, images, disks, logical networks), SDN and network security, and failure triage — starting read-only and confirming before risky changes. WHEN: Azure Local, Azure Stack HCI, Arc resource bridge, custom location, Azure Local VM, Arc VM, AKS on Azure Local, AKS hybrid, SDN, Lifecycle Manager, Azure Local update, disconnected site.

microsoft/azure-local-multi-rack

Plan, deploy, operate, and troubleshoot multi-rack (rack scale) deployments of Azure Local — preintegrated racks scaling to hundreds of machines, built on Network Fabric Controller, Cluster Manager, SAN storage, and managed network fabric. Use for the Microsoft.NetworkCloud and Microsoft.ManagedNetworkFabric control plane. NOT for standard 1-16 node Azure Local, and NOT for rack-aware clusters (two racks as availability zones, up to 8 nodes, synchronous replication) — those are standard scale. WHEN: multi-rack, rack scale Azure Local, aggregation rack, compute rack, Network Fabric Controller, NFC, Cluster Manager, network fabric, isolation domain, az networkcloud, az networkfabric, multi-rack logical network, multi-rack Arc VM.

関連スキル