CommunitySchreiben & Editierengithub.com

microsoft/azure-ai-projects-dotnet

Azure AI Projects SDK für .NET – Hochrangiger Client für Azure AI Foundry-Projekte inklusive Agents, Verbindungen, Datasets, Deployments, Evaluierungen und Indizes.

Was ist azure-ai-projects-dotnet?

Dieses SDK bietet .NET-Entwicklern einen einheitlichen, hochrangigen Client ('AIProjectClient') zur Verwaltung von Azure AI Foundry-Projekten. Es deckt sämtliche Projektressourcen ab: versionierte Agents (auch mit Tools wie Websuche, Code-Interpreter, oder Azure Functions), Konfiguration von Verbindungen zu externen Diensten, Verwaltung von Datasets und Indizes, Modell-Deployments sowie die Durchführung und Nachverfolgung von Evaluierungen. Das SDK unterstützt sowohl einfache, asynchrone Workflows als auch polling-basierte Run-Überwachung und erlaubt über optionale Pakete (z.B. Azure.AI.Projects.OpenAI) die Nutzung von OpenAI-Erweiterungen. Es eignet sich ideal für die Automatisierung des gesamten AI Foundry-Entwicklungszyklus und wird auf Plattformen wie Claude Code, Cursor und Codex genutzt.

Funktioniert mit~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 Schreiben & Editieren skills: steipete/notion, langchain-ai/langchain, bytedance/podcast-generation · View all 6 →

In Ihrer bevorzugten KI fragen

Öffnet einen neuen Chat, in dem dieser Agent-Skill bereits geladen ist.

Dokumentation

Azure.AI.Projects (.NET)

Hochrangiges SDK für Azure AI Foundry-Projektvorgänge einschließlich Agents, Verbindungen, Datasets, Deployments, Evaluierungen und Indizes.

Installation

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

# Optional: Für versionierte Agents mit OpenAI-Erweiterungen
dotnet add package Azure.AI.Projects.OpenAI --prerelease

# Optional: Für Low-Level-Agent-Operationen
dotnet add package Azure.AI.Agents.Persistent --prerelease

Aktuelle Versionen: GA v1.1.0, Preview v1.2.0-beta.5

Umgebungsvariablen

PROJECT_ENDPOINT=https://<resource>.services.ai.azure.com/api/projects/<project>  # Erforderlich: Azure AI-Projektendpunkt
MODEL_DEPLOYMENT_NAME=gpt-4o-mini  # Erforderlich: Name des Modell-Deployments
CONNECTION_NAME=<your-connection-name>  # Optional: Name der Projektverbindung
AI_SEARCH_CONNECTION_NAME=<ai-search-connection>  # Optional: Name der Azure AI Search-Verbindung
AZURE_TOKEN_CREDENTIALS=prod  # Nur erforderlich, wenn DefaultAzureCredential in der Produktion verwendet wird

Authentifizierung

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

var endpoint = Environment.GetEnvironmentVariable("PROJECT_ENDPOINT");
// Lokale Entwicklung: DefaultAzureCredential. Produktion: Setze AZURE_TOKEN_CREDENTIALS=prod oder AZURE_TOKEN_CREDENTIALS=<spezifische_Anmeldeinformationen>
var credential = new DefaultAzureCredential(
    DefaultAzureCredential.DefaultEnvironmentVariableName
);
// Oder verwende direkt eine bestimmte Anmeldeinformation in der Produktion:
// Siehe 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);

Client-Hierarchie

AIProjectClient
├── Agents          → AIProjectAgentsOperations (versionierte Agents)
├── Connections     → ConnectionsClient
├── Datasets        → DatasetsClient
├── Deployments     → DeploymentsClient
├── Evaluations     → EvaluationsClient
├── Evaluators      → EvaluatorsClient
├── Indexes         → IndexesClient
├── Telemetry       → AIProjectTelemetry
├── OpenAI          → ProjectOpenAIClient (Preview)
└── GetPersistentAgentsClient() → PersistentAgentsClient

Kernworkflows

1. Persistent Agents Client abrufen

// Low-Level-Agents-Client vom Projekt-Client abrufen
PersistentAgentsClient agentsClient = projectClient.GetPersistentAgentsClient();

// Agent erstellen
PersistentAgent agent = await agentsClient.Administration.CreateAgentAsync(
    model: "gpt-4o-mini",
    name: "Mathe-Tutor",
    instructions: "Du bist ein persönlicher Mathe-Tutor.");

// Thread und Run erstellen
PersistentAgentThread thread = await agentsClient.Threads.CreateThreadAsync();
await agentsClient.Messages.CreateMessageAsync(thread.Id, MessageRole.User, "Löse 3x + 11 = 14");
ThreadRun run = await agentsClient.Runs.CreateRunAsync(thread.Id, agent.Id);

// Auf Abschluss prüfen (Polling)
do
{
    await Task.Delay(500);
    run = await agentsClient.Runs.GetRunAsync(thread.Id, run.Id);
}
while (run.Status == RunStatus.Queued || run.Status == RunStatus.InProgress);

// Nachrichten abrufen
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);
    }
}

// Bereinigung
await agentsClient.Threads.DeleteThreadAsync(thread.Id);
await agentsClient.Administration.DeleteAgentAsync(agent.Id);

2. Versionierte Agents mit Tools (Preview)

using Azure.AI.Projects.OpenAI;

// Agent mit Web-Suche-Tool erstellen
PromptAgentDefinition agentDefinition = new(model: "gpt-4o-mini")
{
    Instructions = "Du bist ein hilfreicher Assistent, der das Web durchsuchen kann",
    Tools = {
        ResponseTool.CreateWebSearchTool(
            userLocation: WebSearchToolLocation.CreateApproximateLocation(
                country: "US",
                city: "Seattle",
                region: "Washington"
            )
        ),
    }
};

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

// Antwort-Client abrufen
ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion.Name);

// Antwort erstellen
ResponseResult response = responseClient.CreateResponse("Wie ist das Wetter in Seattle?");
Console.WriteLine(response.GetOutputText());

// Bereinigung
projectClient.Agents.DeleteAgentVersion(agentName: agentVersion.Name, agentVersion: agentVersion.Version);

3. Verbindungen

// Alle Verbindungen auflisten
foreach (AIProjectConnection connection in projectClient.Connections.GetConnections())
{
    Console.WriteLine($"{connection.Name}: {connection.ConnectionType}");
}

// Bestimmte Verbindung abrufen
AIProjectConnection conn = projectClient.Connections.GetConnection(
    connectionName, 
    includeCredentials: true);

// Standardverbindung abrufen
AIProjectConnection defaultConn = projectClient.Connections.GetDefaultConnection(
    includeCredentials: false);

4. Deployments

// Alle Deployments auflisten
foreach (AIProjectDeployment deployment in projectClient.Deployments.GetDeployments())
{
    Console.WriteLine($"{deployment.Name}: {deployment.ModelName}");
}

// Nach Publisher filtern
foreach (var deployment in projectClient.Deployments.GetDeployments(modelPublisher: "Microsoft"))
{
    Console.WriteLine(deployment.Name);
}

// Bestimmtes Deployment abrufen
ModelDeployment details = (ModelDeployment)projectClient.Deployments.GetDeployment("gpt-4o-mini");

5. Datasets

// Einzelne Datei hochladen
FileDataset fileDataset = projectClient.Datasets.UploadFile(
    name: "mein-dataset",
    version: "1.0",
    filePath: "data/training.txt",
    connectionName: connectionName);

// Ordner hochladen
FolderDataset folderDataset = projectClient.Datasets.UploadFolder(
    name: "mein-dataset",
    version: "2.0",
    folderPath: "data/training",
    connectionName: connectionName,
    filePattern: new Regex(".*\\.txt"));

// Dataset abrufen
AIProjectDataset dataset = projectClient.Datasets.GetDataset("mein-dataset", "1.0");

// Dataset löschen
projectClient.Datasets.Delete("mein-dataset", "1.0");

6. Indizes

// Azure AI Search Index erstellen
AzureAISearchIndex searchIndex = new(aiSearchConnectionName, aiSearchIndexName)
{
    Description = "Beispielindex"
};

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

// Indizes auflisten
foreach (AIProjectIndex index in projectClient.Indexes.GetIndexes())
{
    Console.WriteLine(index.Name);
}

// Index löschen
projectClient.Indexes.Delete(name: "mein-index", version: "1.0");

7. Evaluierungen

// Evaluierungskonfiguration erstellen
var evaluatorConfig = new EvaluatorConfiguration(id: EvaluatorIDs.Relevance);
evaluatorConfig.InitParams.Add("deployment_name", BinaryData.FromObjectAsJson("gpt-4o"));

// Evaluierung erstellen
Evaluation evaluation = new Evaluation(
    data: new InputDataset("<dataset_id>"),
    evaluators: new Dictionary<string, EvaluatorConfiguration> 
    { 
        { "relevance", evaluatorConfig } 
    }
)
{
    DisplayName = "Beispiel-Evaluierung"
};

// Evaluierung ausführen
Evaluation result = projectClient.Evaluations.Create(evaluation: evaluation);

// Evaluierung abrufen
Evaluation getResult = projectClient.Evaluations.Get(result.Name);

// Evaluierungen auflisten
foreach (var eval in projectClient.Evaluations.GetAll())
{
    Console.WriteLine($"{eval.DisplayName}: {eval.Status}");
}

8. Azure OpenAI Chat-Client abrufen

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("Ungültige 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("Liste alle Regenbogenfarben auf");
Console.WriteLine(result.Content[0].Text);

Verfügbare Agent-Tools

ToolKlasseZweck
Code InterpreterCodeInterpreterToolDefinitionPython-Code ausführen
File SearchFileSearchToolDefinitionHochgeladene Dateien durchsuchen
Function CallingFunctionToolDefinitionBenutzerdefinierte Funktionen aufrufen
Bing GroundingBingGroundingToolDefinitionWebsuche über Bing
Azure AI SearchAzureAISearchToolDefinitionAzure AI-Indizes durchsuchen
OpenAPIOpenApiToolDefinitionExterne APIs aufrufen
Azure FunctionsAzureFunctionToolDefinitionAzure Functions aufrufen
MCPMCPToolDefinitionModel Context Protocol-Tools

Referenz der wichtigsten Typen

TypZweck
AIProjectClientHaupteinstiegspunkt
PersistentAgentsClientLow-Level-Agent-Operationen
PromptAgentDefinitionDefinition versionierter Agenten
AgentVersionInstanz eines versionierten Agenten
AIProjectConnectionVerbindung zu einer Azure-Ressource
AIProjectDeploymentModell-Deployment-Informationen
AIProjectDatasetDataset-Metadaten
AIProjectIndexSuchindex-Metadaten
EvaluationEvaluierungskonfiguration und -ergebnisse

Best Practices

  1. Verwende DefaultAzureCredential für die Authentifizierung in der Produktion
  2. Verwende asynchrone Methoden (*Async) für alle I/O-Operationen
  3. Führe Polling mit angemessenen Verzögerungen (500ms empfohlen) beim Warten auf Runs durch
  4. Räume Ressourcen auf — lösche Threads, Agents und Dateien nach der Nutzung
  5. Verwende versionierte Agents (über Azure.AI.Projects.OpenAI) für Produktionsszenarien
  6. Speichere Verbindungs-IDs anstelle von Namen für Tool-Konfigurationen
  7. Verwende includeCredentials: true nur, wenn Anmeldeinformationen benötigt werden
  8. Behandle Paginierung — verwende AsyncPageable<T> für Auflistungsoperationen

Fehlerbehandlung

using Azure;

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

Verwandte SDKs

SDKZweckInstallation
Azure.AI.ProjectsHochrangiger Projekt-Client (dieses SDK)dotnet add package Azure.AI.Projects
Azure.AI.Agents.PersistentLow-Level-Agent-Operationendotnet add package Azure.AI.Agents.Persistent
Azure.AI.Projects.OpenAIVersionierte Agents mit OpenAIdotnet add package Azure.AI.Projects.OpenAI

Referenzlinks

RessourceURL
NuGet-Pakethttps://www.nuget.org/packages/Azure.AI.Projects
API-Referenzhttps://learn.microsoft.com/dotnet/api/azure.ai.projects
GitHub-Quellehttps://github.com/Azure/azure-sdk-for-net/tree/main/sdk/ai/Azure.AI.Projects
Beispielehttps://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.

Verwandte Skills