PromptAgentBuilderExtensions Methods
AddAISearchTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string, string?) Section titled AddAISearchTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string, string?) extension IResourceBuilder<AzureAISearchToolResource> public static class PromptAgentBuilderExtensions{ public static IResourceBuilder<AzureAISearchToolResource> AddAISearchTool( this IResourceBuilder<AzureCognitiveServicesProjectResource> project, string name, string? indexName = null) { // ... }}Parameters
project IResourceBuilder<AzureCognitiveServicesProjectResource> The ApplicationModel.IResourceBuilder`1 for the Microsoft Foundry project. name string The name of the tool resource. indexName string? optional Optional name of the search index to query. If not specified, the agent must be told which index to use. Returns
IResourceBuilder<AzureAISearchToolResource> A reference to the ApplicationModel.IResourceBuilder`1 for the tool resource. Remarks
PromptAgentBuilderExtensions.WithReference to link it to the backing Azure AI Search resource. AddAzureFunctionTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string, string, string, BinaryData, string, string, string, string) Section titled AddAzureFunctionTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string, string, string, BinaryData, string, string, string, string) extension IResourceBuilder<AzureFunctionToolResource> public static class PromptAgentBuilderExtensions{ public static IResourceBuilder<AzureFunctionToolResource> AddAzureFunctionTool( this IResourceBuilder<AzureCognitiveServicesProjectResource> project, string name, string functionName, string description, BinaryData parameters, string inputQueueEndpoint, string inputQueueName, string outputQueueEndpoint, string outputQueueName) { // ... }}Parameters
project IResourceBuilder<AzureCognitiveServicesProjectResource> The ApplicationModel.IResourceBuilder`1 for the Microsoft Foundry project. name string The name of the tool resource. functionName string The name of the Azure Function. description string A description of what the function does. parameters BinaryData The JSON schema defining the function parameters. inputQueueEndpoint string The Azure Storage Queue endpoint for input binding. inputQueueName string The queue name for input binding. outputQueueEndpoint string The Azure Storage Queue endpoint for output binding. outputQueueName string The queue name for output binding. Returns
IResourceBuilder<AzureFunctionToolResource> A reference to the ApplicationModel.IResourceBuilder`1 for the tool resource. AddAzureFunctionTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string, string, string, string, string, string, string, string) Section titled AddAzureFunctionTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string, string, string, string, string, string, string, string) extension IResourceBuilder<AzureFunctionToolResource> public static class PromptAgentBuilderExtensions{ public static IResourceBuilder<AzureFunctionToolResource> AddAzureFunctionTool( this IResourceBuilder<AzureCognitiveServicesProjectResource> project, string name, string functionName, string description, string parametersJson, string inputQueueEndpoint, string inputQueueName, string outputQueueEndpoint, string outputQueueName) { // ... }}Parameters
project IResourceBuilder<AzureCognitiveServicesProjectResource> The ApplicationModel.IResourceBuilder`1 for the Microsoft Foundry project. name string The name of the tool resource. functionName string The name of the Azure Function. description string A description of what the function does. parametersJson string The JSON schema defining the function parameters as a JSON string. inputQueueEndpoint string The Azure Storage Queue endpoint for input binding. inputQueueName string The queue name for input binding. outputQueueEndpoint string The Azure Storage Queue endpoint for output binding. outputQueueName string The queue name for output binding. Returns
IResourceBuilder<AzureFunctionToolResource> A reference to the ApplicationModel.IResourceBuilder`1 for the tool resource. AddBingGroundingTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string) Section titled AddBingGroundingTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string) extension IResourceBuilder<BingGroundingToolResource> public static class PromptAgentBuilderExtensions{ public static IResourceBuilder<BingGroundingToolResource> AddBingGroundingTool( this IResourceBuilder<AzureCognitiveServicesProjectResource> project, string name) { // ... }}Parameters
project IResourceBuilder<AzureCognitiveServicesProjectResource> The ApplicationModel.IResourceBuilder`1 for the Microsoft Foundry project. name string The name of the tool resource. Returns
IResourceBuilder<BingGroundingToolResource> A reference to the ApplicationModel.IResourceBuilder`1 for the tool resource. Remarks
WithReference overloads to link it to a Bing Search resource. AddCodeInterpreterTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string) Section titled AddCodeInterpreterTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string) extension IResourceBuilder<CodeInterpreterToolResource> public static class PromptAgentBuilderExtensions{ public static IResourceBuilder<CodeInterpreterToolResource> AddCodeInterpreterTool( this IResourceBuilder<AzureCognitiveServicesProjectResource> project, string name) { // ... }}Parameters
project IResourceBuilder<AzureCognitiveServicesProjectResource> The ApplicationModel.IResourceBuilder`1 for the Microsoft Foundry project. name string The name of the tool resource. Returns
IResourceBuilder<CodeInterpreterToolResource> A reference to the ApplicationModel.IResourceBuilder`1 for the tool resource. AddComputerUseTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string, int, int, string) Section titled AddComputerUseTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string, int, int, string) extension IResourceBuilder<ComputerToolResource> public static class PromptAgentBuilderExtensions{ public static IResourceBuilder<ComputerToolResource> AddComputerUseTool( this IResourceBuilder<AzureCognitiveServicesProjectResource> project, string name, int displayWidth = 1024, int displayHeight = 768, string environment = "browser") { // ... }}Parameters
project IResourceBuilder<AzureCognitiveServicesProjectResource> The ApplicationModel.IResourceBuilder`1 for the Microsoft Foundry project. name string The name of the tool resource. displayWidth int optional The width of the display in pixels. displayHeight int optional The height of the display in pixels. environment string optional The environment identifier. Defaults to "browser". Returns
IResourceBuilder<ComputerToolResource> A reference to the ApplicationModel.IResourceBuilder`1 for the tool resource. AddFabricTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string, string[]) Section titled AddFabricTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string, string[]) extension IResourceBuilder<FabricToolResource> public static class PromptAgentBuilderExtensions{ public static IResourceBuilder<FabricToolResource> AddFabricTool( this IResourceBuilder<AzureCognitiveServicesProjectResource> project, string name, params string[] projectConnectionIds) { // ... }}Parameters
project IResourceBuilder<AzureCognitiveServicesProjectResource> The ApplicationModel.IResourceBuilder`1 for the Microsoft Foundry project. name string The name of the tool resource. projectConnectionIds string[] The Foundry project connection IDs for the Fabric data agents. Returns
IResourceBuilder<FabricToolResource> A reference to the ApplicationModel.IResourceBuilder`1 for the tool resource. AddFileSearchTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string, string[]) Section titled AddFileSearchTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string, string[]) extension IResourceBuilder<FileSearchToolResource> public static class PromptAgentBuilderExtensions{ public static IResourceBuilder<FileSearchToolResource> AddFileSearchTool( this IResourceBuilder<AzureCognitiveServicesProjectResource> project, string name, params string[] vectorStoreIds) { // ... }}Parameters
project IResourceBuilder<AzureCognitiveServicesProjectResource> The ApplicationModel.IResourceBuilder`1 for the Microsoft Foundry project. name string The name of the tool resource. vectorStoreIds string[] Optional vector store IDs to search. If empty, the agent's default stores are used. Returns
IResourceBuilder<FileSearchToolResource> A reference to the ApplicationModel.IResourceBuilder`1 for the tool resource. AddFunctionTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string, string, BinaryData, string?, bool?) Section titled AddFunctionTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string, string, BinaryData, string?, bool?) extension IResourceBuilder<FunctionToolResource> public static class PromptAgentBuilderExtensions{ public static IResourceBuilder<FunctionToolResource> AddFunctionTool( this IResourceBuilder<AzureCognitiveServicesProjectResource> project, string name, string functionName, BinaryData parameters, string? description = null, bool? strictModeEnabled = null) { // ... }}Parameters
project IResourceBuilder<AzureCognitiveServicesProjectResource> The ApplicationModel.IResourceBuilder`1 for the Microsoft Foundry project. name string The name of the tool resource. functionName string The name of the function. parameters BinaryData The JSON schema defining the function parameters. description string? optional A description of what the function does. strictModeEnabled bool? optional Whether to enable strict mode for parameter validation. Returns
IResourceBuilder<FunctionToolResource> A reference to the ApplicationModel.IResourceBuilder`1 for the tool resource. AddImageGenerationTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string) Section titled AddImageGenerationTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string) extension IResourceBuilder<ImageGenerationToolResource> public static class PromptAgentBuilderExtensions{ public static IResourceBuilder<ImageGenerationToolResource> AddImageGenerationTool( this IResourceBuilder<AzureCognitiveServicesProjectResource> project, string name) { // ... }}Parameters
project IResourceBuilder<AzureCognitiveServicesProjectResource> The ApplicationModel.IResourceBuilder`1 for the Microsoft Foundry project. name string The name of the tool resource. Returns
IResourceBuilder<ImageGenerationToolResource> A reference to the ApplicationModel.IResourceBuilder`1 for the tool resource. AddPromptAgent(IResourceBuilder<AzureCognitiveServicesProjectResource>, string, IResourceBuilder<FoundryDeploymentResource>, string?) Section titled AddPromptAgent(IResourceBuilder<AzureCognitiveServicesProjectResource>, string, IResourceBuilder<FoundryDeploymentResource>, string?) extension IResourceBuilder<AzurePromptAgentResource> public static class PromptAgentBuilderExtensions{ public static IResourceBuilder<AzurePromptAgentResource> AddPromptAgent( this IResourceBuilder<AzureCognitiveServicesProjectResource> project, string name, IResourceBuilder<FoundryDeploymentResource> model, string? instructions = null) { // ... }}Parameters
project IResourceBuilder<AzureCognitiveServicesProjectResource> The ApplicationModel.IResourceBuilder`1 for the parent Microsoft Foundry project resource. name string The name of the prompt agent. This will be the agent name in Foundry. model IResourceBuilder<FoundryDeploymentResource> The model deployment to use for this agent. instructions string? optional Optional system instructions for the agent. Returns
IResourceBuilder<AzurePromptAgentResource> A reference to the ApplicationModel.IResourceBuilder`1 for the prompt agent resource. Remarks
Prompt agents are always deployed to Azure Foundry, even during local development ( aspire run). Local services communicate with the cloud-provisioned agent using the project endpoint and agent name injected as environment variables.
Tools are project-level resources created with Add*Tool methods and can be reused across multiple agents in the same project.
Examples
var foundry = builder.AddFoundry("aif");var project = foundry.AddProject("proj");var chat = project.AddModelDeployment("gpt41", FoundryModel.OpenAI.Gpt41);
var bing = project.AddBingGroundingTool("bing").WithReference(bingConnection);var aiSearch = project.AddAISearchTool("search").WithReference(searchResource);var codeInterp = project.AddCodeInterpreterTool("code-interp");
project.AddPromptAgent("joker-agent", chat, instructions: "You are good at telling jokes.") .WithTool(bing) .WithTool(aiSearch) .WithTool(codeInterp);AddWebSearchTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string) Section titled AddWebSearchTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string) extension IResourceBuilder<WebSearchToolResource> public static class PromptAgentBuilderExtensions{ public static IResourceBuilder<WebSearchToolResource> AddWebSearchTool( this IResourceBuilder<AzureCognitiveServicesProjectResource> project, string name) { // ... }}Parameters
project IResourceBuilder<AzureCognitiveServicesProjectResource> The ApplicationModel.IResourceBuilder`1 for the Microsoft Foundry project. name string The name of the tool resource. Returns
IResourceBuilder<WebSearchToolResource> A reference to the ApplicationModel.IResourceBuilder`1 for the tool resource. WithCustomTool(IResourceBuilder<AzurePromptAgentResource>, IFoundryTool) Section titled WithCustomTool(IResourceBuilder<AzurePromptAgentResource>, IFoundryTool) extension IResourceBuilder<AzurePromptAgentResource> IFoundryTool interface. public static class PromptAgentBuilderExtensions{ public static IResourceBuilder<AzurePromptAgentResource> WithCustomTool( this IResourceBuilder<AzurePromptAgentResource> builder, IFoundryTool tool) { // ... }}Parameters
builder IResourceBuilder<AzurePromptAgentResource> The prompt agent resource builder. tool IFoundryTool The custom tool implementation. Returns
IResourceBuilder<AzurePromptAgentResource> A reference to the ApplicationModel.IResourceBuilder`1 for chaining. Remarks
FoundryToolResource model. For most scenarios, use the project-level Add*Tool methods and pass tool resources to PromptAgentBuilderExtensions.AddPromptAgent. WithReference(IResourceBuilder<AzureAISearchToolResource>, IResourceBuilder<AzureSearchResource>) Section titled WithReference(IResourceBuilder<AzureAISearchToolResource>, IResourceBuilder<AzureSearchResource>) extension IResourceBuilder<AzureAISearchToolResource> Azure.AzureSearchResource, creating the necessary Foundry project connection and role assignments. public static class PromptAgentBuilderExtensions{ public static IResourceBuilder<AzureAISearchToolResource> WithReference( this IResourceBuilder<AzureAISearchToolResource> tool, IResourceBuilder<AzureSearchResource> search) { // ... }}Parameters
tool IResourceBuilder<AzureAISearchToolResource> The Azure AI Search tool resource builder. search IResourceBuilder<AzureSearchResource> The Azure AI Search resource to use for grounding. Returns
IResourceBuilder<AzureAISearchToolResource> A reference to the ApplicationModel.IResourceBuilder`1 for chaining. WithReference(IResourceBuilder<BingGroundingToolResource>, IResourceBuilder<BingGroundingConnectionResource>) Section titled WithReference(IResourceBuilder<BingGroundingToolResource>, IResourceBuilder<BingGroundingConnectionResource>) extension IResourceBuilder<BingGroundingToolResource> public static class PromptAgentBuilderExtensions{ public static IResourceBuilder<BingGroundingToolResource> WithReference( this IResourceBuilder<BingGroundingToolResource> tool, IResourceBuilder<BingGroundingConnectionResource> bingConnection) { // ... }}Parameters
tool IResourceBuilder<BingGroundingToolResource> The Bing Grounding tool resource builder. bingConnection IResourceBuilder<BingGroundingConnectionResource> The Bing grounding connection resource builder created by AzureCognitiveServicesProjectConnectionsBuilderExtensions.AddBingGroundingConnection or AzureCognitiveServicesProjectConnectionsBuilderExtensions.AddBingGroundingConnection. Returns
IResourceBuilder<BingGroundingToolResource> A reference to the ApplicationModel.IResourceBuilder`1 for chaining. WithReference(IResourceBuilder<BingGroundingToolResource>, string) Section titled WithReference(IResourceBuilder<BingGroundingToolResource>, string) extension IResourceBuilder<BingGroundingToolResource> public static class PromptAgentBuilderExtensions{ public static IResourceBuilder<BingGroundingToolResource> WithReference( this IResourceBuilder<BingGroundingToolResource> tool, string bingResourceId) { // ... }}Parameters
tool IResourceBuilder<BingGroundingToolResource> The Bing Grounding tool resource builder. bingResourceId string The full Azure resource ID of the Bing Search resource (e.g., /subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.Bing/accounts/{name}). Returns
IResourceBuilder<BingGroundingToolResource> A reference to the ApplicationModel.IResourceBuilder`1 for chaining. WithReference(IResourceBuilder<BingGroundingToolResource>, IResourceBuilder<ParameterResource>) Section titled WithReference(IResourceBuilder<BingGroundingToolResource>, IResourceBuilder<ParameterResource>) extension IResourceBuilder<BingGroundingToolResource> public static class PromptAgentBuilderExtensions{ public static IResourceBuilder<BingGroundingToolResource> WithReference( this IResourceBuilder<BingGroundingToolResource> tool, IResourceBuilder<ParameterResource> bingResourceId) { // ... }}Parameters
tool IResourceBuilder<BingGroundingToolResource> The Bing Grounding tool resource builder. bingResourceId IResourceBuilder<ParameterResource> A parameter resource containing the full Azure resource ID of the Bing Search resource. Returns
IResourceBuilder<BingGroundingToolResource> A reference to the ApplicationModel.IResourceBuilder`1 for chaining. WithTool(IResourceBuilder<AzurePromptAgentResource>, IResourceBuilder<FoundryToolResource>) Section titled WithTool(IResourceBuilder<AzurePromptAgentResource>, IResourceBuilder<FoundryToolResource>) extension IResourceBuilder<AzurePromptAgentResource> public static class PromptAgentBuilderExtensions{ public static IResourceBuilder<AzurePromptAgentResource> WithTool( this IResourceBuilder<AzurePromptAgentResource> agent, IResourceBuilder<FoundryToolResource> tool) { // ... }}Parameters
agent IResourceBuilder<AzurePromptAgentResource> The prompt agent resource builder. tool IResourceBuilder<FoundryToolResource> The tool resource to attach to this agent. Returns
IResourceBuilder<AzurePromptAgentResource> A reference to the ApplicationModel.IResourceBuilder`1 for chaining.