-
Notifications
You must be signed in to change notification settings - Fork 660
.NET: Azure.AI.Agents Package Split + Initial Extensions #1657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6dcf241
f19c68c
f98ddc0
41d3ae4
292238f
04b5cc9
698c859
37d44cf
959361e
2225418
ae8eceb
74de27a
fd19888
0a4dd8a
34ac7dd
4a10881
f28fdef
45cffb8
9b0f064
1376d2a
dc4dd2e
d6ee1b7
60b9ad3
ff71122
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -17,8 +17,8 @@ | |||||
| <PackageVersion Include="Aspire.Microsoft.Azure.Cosmos" Version="$(AspireAppHostSdkVersion)" /> | ||||||
| <PackageVersion Include="CommunityToolkit.Aspire.OllamaSharp" Version="9.8.0" /> | ||||||
| <!-- Azure.* --> | ||||||
| <PackageVersion Include="Azure.AI.Agents" Version="2.0.0-alpha.20251016.2" /> | ||||||
| <PackageVersion Include="Azure.AI.Agents.Persistent" Version="1.2.0-beta.7" /> | ||||||
| <PackageVersion Include="Azure.AI.Agents" Version="2.0.0-alpha.20251024.3" /> | ||||||
| <PackageVersion Include="Azure.AI.Agents.Persistent" Version="1.2.0-beta.6" /> | ||||||
|
||||||
| <PackageVersion Include="Azure.AI.Agents.Persistent" Version="1.2.0-beta.6" /> | |
| <PackageVersion Include="Azure.AI.Agents.Persistent" Version="1.2.0-beta.7" /> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>net9.0</TargetFramework> | ||
|
|
||
| <Nullable>enable</Nullable> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <NoWarn>$(NoWarn);IDE0059</NoWarn> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Azure.AI.Agents" /> | ||
| <PackageReference Include="Azure.Identity" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\..\..\..\src\Microsoft.Agents.AI.AzureAIAgents\Microsoft.Agents.AI.AzureAIAgents.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // Copyright (c) Microsoft. All rights reserved. | ||
|
|
||
| // This sample shows how to create and use a simple AI agent with Azure Foundry Agents as the backend. | ||
rogerbarreto marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| using Azure.AI.Agents; | ||
| using Azure.Identity; | ||
| using Microsoft.Agents.AI; | ||
|
|
||
| var endpoint = Environment.GetEnvironmentVariable("AZURE_FOUNDRY_PROJECT_ENDPOINT") ?? throw new InvalidOperationException("AZURE_FOUNDRY_PROJECT_ENDPOINT is not set."); | ||
| var deploymentName = Environment.GetEnvironmentVariable("AZURE_FOUNDRY_PROJECT_DEPLOYMENT_NAME") ?? "gpt-4o-mini"; | ||
|
|
||
| const string JokerInstructions = "You are good at telling jokes."; | ||
| const string JokerName = "JokerAgent"; | ||
|
|
||
| // Get a client to create/retrieve server side agents with. | ||
| var agentsClient = new AgentsClient(new Uri(endpoint), new AzureCliCredential()); | ||
|
|
||
| // Define the agent you want to create. | ||
| var agentDefinition = new PromptAgentDefinition(model: deploymentName) { Instructions = JokerInstructions }; | ||
|
|
||
| // You can create a server side agent with the Azure.AI.Agents SDK. | ||
| var agentVersion = agentsClient.CreateAgentVersion(agentName: JokerName, definition: agentDefinition).Value; | ||
|
|
||
| // You can retrieve an already created server side agent as an AIAgent. | ||
| AIAgent existingAgent = await agentsClient.GetAIAgentAsync(deploymentName, agentVersion.Name); | ||
|
|
||
| // You can also create a server side persistent agent and return it as an AIAgent directly. | ||
| var createdAgent = agentsClient.CreateAIAgent(deploymentName, name: JokerName, instructions: JokerInstructions); | ||
|
|
||
| // You can then invoke the agent like any other AIAgent. | ||
| AgentThread thread = existingAgent.GetNewThread(); | ||
| Console.WriteLine(await existingAgent.RunAsync("Tell me a joke about a pirate.", thread)); | ||
|
|
||
| // Cleanup by agent name (removes both agent versions created by existingAgent + createdAgent). | ||
| await agentsClient.DeleteAgentAsync(agentVersion.Name); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # Prerequisites | ||
|
|
||
| Before you begin, ensure you have the following prerequisites: | ||
|
|
||
| - .NET 8.0 SDK or later | ||
| - Azure Foundry service endpoint and deployment configured | ||
| - Azure CLI installed and authenticated (for Azure credential authentication) | ||
|
|
||
| **Note**: This demo uses Azure CLI credentials for authentication. Make sure you're logged in with `az login` and have access to the Azure Foundry resource. For more information, see the [Azure CLI documentation](https://learn.microsoft.com/cli/azure/authenticate-azure-cli-interactively). | ||
|
|
||
| Set the following environment variables: | ||
|
|
||
| ```powershell | ||
| $env:AZURE_FOUNDRY_PROJECT_ENDPOINT="https://your-foundry-service.services.ai.azure.com/api/projects/your-foundry-project" # Replace with your Azure Foundry resource endpoint | ||
rogerbarreto marked this conversation as resolved.
Show resolved
Hide resolved
rogerbarreto marked this conversation as resolved.
Show resolved
Hide resolved
rogerbarreto marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| $env:AZURE_FOUNDRY_PROJECT_DEPLOYMENT_NAME="gpt-4o-mini" # Optional, defaults to gpt-4o-mini | ||
rogerbarreto marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ``` | ||
Uh oh!
There was an error while loading. Please reload this page.