PromptAgentBuilderExtensions Methods
AddAISearchTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string, string?)Section titled AddAISearchTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string, string?)extensionIResourceBuilder<AzureAISearchToolResource>public static class PromptAgentBuilderExtensions{ public static IResourceBuilder<AzureAISearchToolResource> AddAISearchTool( this IResourceBuilder<AzureCognitiveServicesProjectResource> project, string name, string? indexName = null) { // ... }}Parameters
projectIResourceBuilder<AzureCognitiveServicesProjectResource>The ApplicationModel.IResourceBuilder`1 for the Microsoft Foundry project.namestringThe name of the tool resource.indexNamestring?optionalOptional 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)extensionIResourceBuilder<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
projectIResourceBuilder<AzureCognitiveServicesProjectResource>The ApplicationModel.IResourceBuilder`1 for the Microsoft Foundry project.namestringThe name of the tool resource.functionNamestringThe name of the Azure Function.descriptionstringA description of what the function does.parametersBinaryDataThe JSON schema defining the function parameters.inputQueueEndpointstringThe Azure Storage Queue endpoint for input binding.inputQueueNamestringThe queue name for input binding.outputQueueEndpointstringThe Azure Storage Queue endpoint for output binding.outputQueueNamestringThe 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)extensionIResourceBuilder<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
projectIResourceBuilder<AzureCognitiveServicesProjectResource>The ApplicationModel.IResourceBuilder`1 for the Microsoft Foundry project.namestringThe name of the tool resource.functionNamestringThe name of the Azure Function.descriptionstringA description of what the function does.parametersJsonstringThe JSON schema defining the function parameters as a JSON string.inputQueueEndpointstringThe Azure Storage Queue endpoint for input binding.inputQueueNamestringThe queue name for input binding.outputQueueEndpointstringThe Azure Storage Queue endpoint for output binding.outputQueueNamestringThe 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)extensionIResourceBuilder<BingGroundingToolResource>public static class PromptAgentBuilderExtensions{ public static IResourceBuilder<BingGroundingToolResource> AddBingGroundingTool( this IResourceBuilder<AzureCognitiveServicesProjectResource> project, string name) { // ... }}Parameters
projectIResourceBuilder<AzureCognitiveServicesProjectResource>The ApplicationModel.IResourceBuilder`1 for the Microsoft Foundry project.namestringThe 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)extensionIResourceBuilder<CodeInterpreterToolResource>public static class PromptAgentBuilderExtensions{ public static IResourceBuilder<CodeInterpreterToolResource> AddCodeInterpreterTool( this IResourceBuilder<AzureCognitiveServicesProjectResource> project, string name) { // ... }}Parameters
projectIResourceBuilder<AzureCognitiveServicesProjectResource>The ApplicationModel.IResourceBuilder`1 for the Microsoft Foundry project.namestringThe 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)extensionIResourceBuilder<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
projectIResourceBuilder<AzureCognitiveServicesProjectResource>The ApplicationModel.IResourceBuilder`1 for the Microsoft Foundry project.namestringThe name of the tool resource.displayWidthintoptionalThe width of the display in pixels.displayHeightintoptionalThe height of the display in pixels.environmentstringoptionalThe 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[])extensionIResourceBuilder<FabricToolResource>public static class PromptAgentBuilderExtensions{ public static IResourceBuilder<FabricToolResource> AddFabricTool( this IResourceBuilder<AzureCognitiveServicesProjectResource> project, string name, params string[] projectConnectionIds) { // ... }}Parameters
projectIResourceBuilder<AzureCognitiveServicesProjectResource>The ApplicationModel.IResourceBuilder`1 for the Microsoft Foundry project.namestringThe name of the tool resource.projectConnectionIdsstring[]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[])extensionIResourceBuilder<FileSearchToolResource>public static class PromptAgentBuilderExtensions{ public static IResourceBuilder<FileSearchToolResource> AddFileSearchTool( this IResourceBuilder<AzureCognitiveServicesProjectResource> project, string name, params string[] vectorStoreIds) { // ... }}Parameters
projectIResourceBuilder<AzureCognitiveServicesProjectResource>The ApplicationModel.IResourceBuilder`1 for the Microsoft Foundry project.namestringThe name of the tool resource.vectorStoreIdsstring[]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?)extensionIResourceBuilder<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
projectIResourceBuilder<AzureCognitiveServicesProjectResource>The ApplicationModel.IResourceBuilder`1 for the Microsoft Foundry project.namestringThe name of the tool resource.functionNamestringThe name of the function.parametersBinaryDataThe JSON schema defining the function parameters.descriptionstring?optionalA description of what the function does.strictModeEnabledbool?optionalWhether 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)extensionIResourceBuilder<ImageGenerationToolResource>public static class PromptAgentBuilderExtensions{ public static IResourceBuilder<ImageGenerationToolResource> AddImageGenerationTool( this IResourceBuilder<AzureCognitiveServicesProjectResource> project, string name) { // ... }}Parameters
projectIResourceBuilder<AzureCognitiveServicesProjectResource>The ApplicationModel.IResourceBuilder`1 for the Microsoft Foundry project.namestringThe 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?)extensionIResourceBuilder<AzurePromptAgentResource>public static class PromptAgentBuilderExtensions{ public static IResourceBuilder<AzurePromptAgentResource> AddPromptAgent( this IResourceBuilder<AzureCognitiveServicesProjectResource> project, string name, IResourceBuilder<FoundryDeploymentResource> model, string? instructions = null) { // ... }}Parameters
projectIResourceBuilder<AzureCognitiveServicesProjectResource>The ApplicationModel.IResourceBuilder`1 for the parent Microsoft Foundry project resource.namestringThe name of the prompt agent. This will be the agent name in Foundry.modelIResourceBuilder<FoundryDeploymentResource>The model deployment to use for this agent.instructionsstring?optionalOptional 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)extensionIResourceBuilder<WebSearchToolResource>public static class PromptAgentBuilderExtensions{ public static IResourceBuilder<WebSearchToolResource> AddWebSearchTool( this IResourceBuilder<AzureCognitiveServicesProjectResource> project, string name) { // ... }}Parameters
projectIResourceBuilder<AzureCognitiveServicesProjectResource>The ApplicationModel.IResourceBuilder`1 for the Microsoft Foundry project.namestringThe 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)extensionIResourceBuilder<AzurePromptAgentResource>IFoundryTool interface. public static class PromptAgentBuilderExtensions{ public static IResourceBuilder<AzurePromptAgentResource> WithCustomTool( this IResourceBuilder<AzurePromptAgentResource> builder, IFoundryTool tool) { // ... }}Parameters
builderIResourceBuilder<AzurePromptAgentResource>The prompt agent resource builder.toolIFoundryToolThe 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>)extensionIResourceBuilder<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
toolIResourceBuilder<AzureAISearchToolResource>The Azure AI Search tool resource builder.searchIResourceBuilder<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>)extensionIResourceBuilder<BingGroundingToolResource>public static class PromptAgentBuilderExtensions{ public static IResourceBuilder<BingGroundingToolResource> WithReference( this IResourceBuilder<BingGroundingToolResource> tool, IResourceBuilder<BingGroundingConnectionResource> bingConnection) { // ... }}Parameters
toolIResourceBuilder<BingGroundingToolResource>The Bing Grounding tool resource builder.bingConnectionIResourceBuilder<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)extensionIResourceBuilder<BingGroundingToolResource>public static class PromptAgentBuilderExtensions{ public static IResourceBuilder<BingGroundingToolResource> WithReference( this IResourceBuilder<BingGroundingToolResource> tool, string bingResourceId) { // ... }}Parameters
toolIResourceBuilder<BingGroundingToolResource>The Bing Grounding tool resource builder.bingResourceIdstring 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>)extensionIResourceBuilder<BingGroundingToolResource>public static class PromptAgentBuilderExtensions{ public static IResourceBuilder<BingGroundingToolResource> WithReference( this IResourceBuilder<BingGroundingToolResource> tool, IResourceBuilder<ParameterResource> bingResourceId) { // ... }}Parameters
toolIResourceBuilder<BingGroundingToolResource>The Bing Grounding tool resource builder.bingResourceIdIResourceBuilder<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>)extensionIResourceBuilder<AzurePromptAgentResource>public static class PromptAgentBuilderExtensions{ public static IResourceBuilder<AzurePromptAgentResource> WithTool( this IResourceBuilder<AzurePromptAgentResource> agent, IResourceBuilder<FoundryToolResource> tool) { // ... }}Parameters
agentIResourceBuilder<AzurePromptAgentResource>The prompt agent resource builder.toolIResourceBuilder<FoundryToolResource>The tool resource to attach to this agent.Returns
IResourceBuilder<AzurePromptAgentResource>A reference to the ApplicationModel.IResourceBuilder`1 for chaining.