[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-25157551-1f22-4d21-92c9-fc808a697060":3,"$fZtHHI5_TCZcRXI6VGfe2doh9YFPrGNtDZvoHd6tI34Y":43},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":34},"25157551-1f22-4d21-92c9-fc808a697060","azure-ai-projects-dotnet","Azure AI Projects SDK for .NET。针对Azure AI Foundry项目的客户端，包括代理、连接、数据集、部署、评估和索引。","cat_coding_devops","mod_coding","sickn33,coding","---\nname: azure-ai-projects-dotnet\ndescription: Azure AI Projects SDK for .NET. High-level client for Azure AI Foundry projects including agents, connections, datasets, deployments, evaluations, and indexes.\nrisk: unknown\nsource: community\ndate_added: '2026-02-27'\n---\n\n# Azure.AI.Projects (.NET)\n\nHigh-level SDK for Azure AI Foundry project operations including agents, connections, datasets, deployments, evaluations, and indexes.\n\n## Installation\n\n```bash\ndotnet add package Azure.AI.Projects\ndotnet add package Azure.Identity\n\n# Optional: For versioned agents with OpenAI extensions\ndotnet add package Azure.AI.Projects.OpenAI --prerelease\n\n# Optional: For low-level agent operations\ndotnet add package Azure.AI.Agents.Persistent --prerelease\n```\n\n**Current Versions**: GA v1.1.0, Preview v1.2.0-beta.5\n\n## Environment Variables\n\n```bash\nPROJECT_ENDPOINT=https:\u002F\u002F\u003Cresource>.services.ai.azure.com\u002Fapi\u002Fprojects\u002F\u003Cproject>\nMODEL_DEPLOYMENT_NAME=gpt-4o-mini\nCONNECTION_NAME=\u003Cyour-connection-name>\nAI_SEARCH_CONNECTION_NAME=\u003Cai-search-connection>\n```\n\n## Authentication\n\n```csharp\nusing Azure.Identity;\nusing Azure.AI.Projects;\n\nvar endpoint = Environment.GetEnvironmentVariable(\"PROJECT_ENDPOINT\");\nAIProjectClient projectClient = new AIProjectClient(\n    new Uri(endpoint), \n    new DefaultAzureCredential());\n```\n\n## Client Hierarchy\n\n```\nAIProjectClient\n├── Agents          → AIProjectAgentsOperations (versioned agents)\n├── Connections     → ConnectionsClient\n├── Datasets        → DatasetsClient\n├── Deployments     → DeploymentsClient\n├── Evaluations     → EvaluationsClient\n├── Evaluators      → EvaluatorsClient\n├── Indexes         → IndexesClient\n├── Telemetry       → AIProjectTelemetry\n├── OpenAI          → ProjectOpenAIClient (preview)\n└── GetPersistentAgentsClient() → PersistentAgentsClient\n```\n\n## Core Workflows\n\n### 1. Get Persistent Agents Client\n\n```csharp\n\u002F\u002F Get low-level agents client from project client\nPersistentAgentsClient agentsClient = projectClient.GetPersistentAgentsClient();\n\n\u002F\u002F Create agent\nPersistentAgent agent = await agentsClient.Administration.CreateAgentAsync(\n    model: \"gpt-4o-mini\",\n    name: \"Math Tutor\",\n    instructions: \"You are a personal math tutor.\");\n\n\u002F\u002F Create thread and run\nPersistentAgentThread thread = await agentsClient.Threads.CreateThreadAsync();\nawait agentsClient.Messages.CreateMessageAsync(thread.Id, MessageRole.User, \"Solve 3x + 11 = 14\");\nThreadRun run = await agentsClient.Runs.CreateRunAsync(thread.Id, agent.Id);\n\n\u002F\u002F Poll for completion\ndo\n{\n    await Task.Delay(500);\n    run = await agentsClient.Runs.GetRunAsync(thread.Id, run.Id);\n}\nwhile (run.Status == RunStatus.Queued || run.Status == RunStatus.InProgress);\n\n\u002F\u002F Get messages\nawait foreach (var msg in agentsClient.Messages.GetMessagesAsync(thread.Id))\n{\n    foreach (var content in msg.ContentItems)\n    {\n        if (content is MessageTextContent textContent)\n            Console.WriteLine(textContent.Text);\n    }\n}\n\n\u002F\u002F Cleanup\nawait agentsClient.Threads.DeleteThreadAsync(thread.Id);\nawait agentsClient.Administration.DeleteAgentAsync(agent.Id);\n```\n\n### 2. Versioned Agents with Tools (Preview)\n\n```csharp\nusing Azure.AI.Projects.OpenAI;\n\n\u002F\u002F Create agent with web search tool\nPromptAgentDefinition agentDefinition = new(model: \"gpt-4o-mini\")\n{\n    Instructions = \"You are a helpful assistant that can search the web\",\n    Tools = {\n        ResponseTool.CreateWebSearchTool(\n            userLocation: WebSearchToolLocation.CreateApproximateLocation(\n                country: \"US\",\n                city: \"Seattle\",\n                region: \"Washington\"\n            )\n        ),\n    }\n};\n\nAgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync(\n    agentName: \"myAgent\",\n    options: new(agentDefinition));\n\n\u002F\u002F Get response client\nProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion.Name);\n\n\u002F\u002F Create response\nResponseResult response = responseClient.CreateResponse(\"What's the weather in Seattle?\");\nConsole.WriteLine(response.GetOutputText());\n\n\u002F\u002F Cleanup\nprojectClient.Agents.DeleteAgentVersion(agentName: agentVersion.Name, agentVersion: agentVersion.Version);\n```\n\n### 3. Connections\n\n```csharp\n\u002F\u002F List all connections\nforeach (AIProjectConnection connection in projectClient.Connections.GetConnections())\n{\n    Console.WriteLine($\"{connection.Name}: {connection.ConnectionType}\");\n}\n\n\u002F\u002F Get specific connection\nAIProjectConnection conn = projectClient.Connections.GetConnection(\n    connectionName, \n    includeCredentials: true);\n\n\u002F\u002F Get default connection\nAIProjectConnection defaultConn = projectClient.Connections.GetDefaultConnection(\n    includeCredentials: false);\n```\n\n### 4. Deployments\n\n```csharp\n\u002F\u002F List all deployments\nforeach (AIProjectDeployment deployment in projectClient.Deployments.GetDeployments())\n{\n    Console.WriteLine($\"{deployment.Name}: {deployment.ModelName}\");\n}\n\n\u002F\u002F Filter by publisher\nforeach (var deployment in projectClient.Deployments.GetDeployments(modelPublisher: \"Microsoft\"))\n{\n    Console.WriteLine(deployment.Name);\n}\n\n\u002F\u002F Get specific deployment\nModelDeployment details = (ModelDeployment)projectClient.Deployments.GetDeployment(\"gpt-4o-mini\");\n```\n\n### 5. Datasets\n\n```csharp\n\u002F\u002F Upload single file\nFileDataset fileDataset = projectClient.Datasets.UploadFile(\n    name: \"my-dataset\",\n    version: \"1.0\",\n    filePath: \"data\u002Ftraining.txt\",\n    connectionName: connectionName);\n\n\u002F\u002F Upload folder\nFolderDataset folderDataset = projectClient.Datasets.UploadFolder(\n    name: \"my-dataset\",\n    version: \"2.0\",\n    folderPath: \"data\u002Ftraining\",\n    connectionName: connectionName,\n    filePattern: new Regex(\".*\\\\.txt\"));\n\n\u002F\u002F Get dataset\nAIProjectDataset dataset = projectClient.Datasets.GetDataset(\"my-dataset\", \"1.0\");\n\n\u002F\u002F Delete dataset\nprojectClient.Datasets.Delete(\"my-dataset\", \"1.0\");\n```\n\n### 6. Indexes\n\n```csharp\n\u002F\u002F Create Azure AI Search index\nAzureAISearchIndex searchIndex = new(aiSearchConnectionName, aiSearchIndexName)\n{\n    Description = \"Sample Index\"\n};\n\nsearchIndex = (AzureAISearchIndex)projectClient.Indexes.CreateOrUpdate(\n    name: \"my-index\",\n    version: \"1.0\",\n    index: searchIndex);\n\n\u002F\u002F List indexes\nforeach (AIProjectIndex index in projectClient.Indexes.GetIndexes())\n{\n    Console.WriteLine(index.Name);\n}\n\n\u002F\u002F Delete index\nprojectClient.Indexes.Delete(name: \"my-index\", version: \"1.0\");\n```\n\n### 7. Evaluations\n\n```csharp\n\u002F\u002F Create evaluation configuration\nvar evaluatorConfig = new EvaluatorConfiguration(id: EvaluatorIDs.Relevance);\nevaluatorConfig.InitParams.Add(\"deployment_name\", BinaryData.FromObjectAsJson(\"gpt-4o\"));\n\n\u002F\u002F Create evaluation\nEvaluation evaluation = new Evaluation(\n    data: new InputDataset(\"\u003Cdataset_id>\"),\n    evaluators: new Dictionary\u003Cstring, EvaluatorConfiguration> \n    { \n        { \"relevance\", evaluatorConfig } \n    }\n)\n{\n    DisplayName = \"Sample Evaluation\"\n};\n\n\u002F\u002F Run evaluation\nEvaluation result = projectClient.Evaluations.Create(evaluation: evaluation);\n\n\u002F\u002F Get evaluation\nEvaluation getResult = projectClient.Evaluations.Get(result.Name);\n\n\u002F\u002F List evaluations\nforeach (var eval in projectClient.Evaluations.GetAll())\n{\n    Console.WriteLine($\"{eval.DisplayName}: {eval.Status}\");\n}\n```\n\n### 8. Get Azure OpenAI Chat Client\n\n```csharp\nusing Azure.AI.OpenAI;\nusing OpenAI.Chat;\n\nClientConnection connection = projectClient.GetConnection(typeof(AzureOpenAIClient).FullName!);\n\nif (!connection.TryGetLocatorAsUri(out Uri uri) || uri is null)\n    throw new InvalidOperationException(\"Invalid URI.\");\n\nuri = new Uri($\"https:\u002F\u002F{uri.Host}\");\n\nAzureOpenAIClient azureOpenAIClient = new AzureOpenAIClient(uri, new DefaultAzureCredential());\nChatClient chatClient = azureOpenAIClient.GetChatClient(\"gpt-4o-mini\");\n\nChatCompletion result = chatClient.CompleteChat(\"List all rainbow colors\");\nConsole.WriteLine(result.Content[0].Text);\n```\n\n## Available Agent Tools\n\n| Tool | Class | Purpose |\n|------|-------|---------|\n| Code Interpreter | `CodeInterpreterToolDefinition` | Execute Python code |\n| File Search | `FileSearchToolDefinition` | Search uploaded files |\n| Function Calling | `FunctionToolDefinition` | Call custom functions |\n| Bing Grounding | `BingGroundingToolDefinition` | Web search via Bing |\n| Azure AI Search | `AzureAISearchToolDefinition` | Search Azure AI indexes |\n| OpenAPI | `OpenApiToolDefinition` | Call external APIs |\n| Azure Functions | `AzureFunctionToolDefinition` | Invoke Azure Functions |\n| MCP | `MCPToolDefinition` | Model Context Protocol tools |\n\n## Key Types Reference\n\n| Type | Purpose |\n|------|---------|\n| `AIProjectClient` | Main entry point |\n| `PersistentAgentsClient` | Low-level agent operations |\n| `PromptAgentDefinition` | Versioned agent definition |\n| `AgentVersion` | Versioned agent instance |\n| `AIProjectConnection` | Connection to Azure resource |\n| `AIProjectDeployment` | Model deployment info |\n| `AIProjectDataset` | Dataset metadata |\n| `AIProjectIndex` | Search index metadata |\n| `Evaluation` | Evaluation configuration and results |\n\n## Best Practices\n\n1. **Use `DefaultAzureCredential`** for production authentication\n2. **Use async methods** (`*Async`) for all I\u002FO operations\n3. **Poll with appropriate delays** (500ms recommended) when waiting for runs\n4. **Clean up resources** — delete threads, agents, and files when done\n5. **Use versioned agents** (via `Azure.AI.Projects.OpenAI`) for production scenarios\n6. **Store connection IDs** rather than names for tool configurations\n7. **Use `includeCredentials: true`** only when credentials are needed\n8. **Handle pagination** — use `AsyncPageable\u003CT>` for listing operations\n\n## Error Handling\n\n```csharp\nusing Azure;\n\ntry\n{\n    var result = await projectClient.Evaluations.CreateAsync(evaluation);\n}\ncatch (RequestFailedException ex)\n{\n    Console.WriteLine($\"Error: {ex.Status} - {ex.ErrorCode}: {ex.Message}\");\n}\n```\n\n## Related SDKs\n\n| SDK | Purpose | Install |\n|-----|---------|---------|\n| `Azure.AI.Projects` | High-level project client (this SDK) | `dotnet add package Azure.AI.Projects` |\n| `Azure.AI.Agents.Persistent` | Low-level agent operations | `dotnet add package Azure.AI.Agents.Persistent` |\n| `Azure.AI.Projects.OpenAI` | Versioned agents with OpenAI | `dotnet add package Azure.AI.Projects.OpenAI` |\n\n## Reference Links\n\n| Resource | URL |\n|----------|-----|\n| NuGet Package | https:\u002F\u002Fwww.nuget.org\u002Fpackages\u002FAzure.AI.Projects |\n| API Reference | https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fapi\u002Fazure.ai.projects |\n| GitHub Source | https:\u002F\u002Fgithub.com\u002FAzure\u002Fazure-sdk-for-net\u002Ftree\u002Fmain\u002Fsdk\u002Fai\u002FAzure.AI.Projects |\n| Samples | https:\u002F\u002Fgithub.com\u002FAzure\u002Fazure-sdk-for-net\u002Ftree\u002Fmain\u002Fsdk\u002Fai\u002FAzure.AI.Projects\u002Fsamples |\n\n## When to Use\nThis skill is applicable to execute the workflow or actions described in the overview.\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,243,426,"2026-05-16 13:05:18",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"编程开发","coding","mdi-code-braces","代码生成、调试、审查，提升开发效率",2,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":32,"skillCount":33,"createdAt":26},"DevOps","devops","mdi-cog-outline","CI\u002FCD、容器化、部署运维",3,162,[35],{"id":36,"skillId":4,"version":37,"fileName":38,"fileSize":39,"filePath":40,"fileHash":41,"manifest":42,"createdAt":19},"1cfd3154-ee37-4b2a-a60a-a995fd718ea2","1.0.0","azure-ai-projects-dotnet.zip",3875,"uploads\u002Fskills\u002F25157551-1f22-4d21-92c9-fc808a697060\u002Fazure-ai-projects-dotnet.zip","8a33e32cdbfe888805f3b136c999e946d8f9f375badfb35522c6a61bf993957c","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":11156}]",{"code":44,"message":45,"data":46},200,"success",{"items":47,"stats":48,"page":51},[],{"averageRating":49,"totalRatings":49,"ratingCounts":50},0,[49,49,49,49,49],{"limit":52,"offset":49,"hasMore":53,"nextOffset":52,"ratedOnly":16},15,false]