FoundryToolboxBuilderExtensions Methods
ClassMethods9 members
Extension methods for adding Microsoft Foundry Toolbox resources and tools.
AddToolbox(IResourceBuilder<AzureCognitiveServicesProjectResource>, string, Action<FoundryToolboxResource>)Section titled AddToolbox(IResourceBuilder<AzureCognitiveServicesProjectResource>, string, Action<FoundryToolboxResource>)extensionIResourceBuilder<FoundryToolboxResource> Adds a Microsoft Foundry Toolbox endpoint to a Microsoft Foundry project.
public static class FoundryToolboxBuilderExtensions{ public static IResourceBuilder<FoundryToolboxResource> AddToolbox( this IResourceBuilder<AzureCognitiveServicesProjectResource> builder, string name, Action<FoundryToolboxResource>? configure = null) { // ... }}Parameters
builderIResourceBuilder<AzureCognitiveServicesProjectResource>The resource builder for the Microsoft Foundry project.namestringThe Toolbox name.configureAction<FoundryToolboxResource>optionalOptional callback used to configure the Toolbox resource.Returns
IResourceBuilder<FoundryToolboxResource>A reference to the ApplicationModel.IResourceBuilder`1 for the Toolbox resource.Remarks
Aspire reuses the current default version when its configuration matches. Otherwise, it creates and promotes a new immutable version. The
FoundryToolboxResource.Version property pins the version used by consumers in the MCP endpoint URI; the version selected by the most recent reconciliation is exposed via FoundryToolboxResource.DeployedVersion. Examples
var foundry = builder.AddFoundry("foundry");var project = foundry.AddProject("project");var toolbox = project.AddToolbox("field-tools") .WithWebSearchTool();
builder.AddProject<Projects.Worker>("worker") .WithReference(toolbox) .WaitFor(toolbox);AsExisting(IResourceBuilder<FoundryToolboxResource>)Section titled AsExisting(IResourceBuilder<FoundryToolboxResource>)extensionIResourceBuilder<FoundryToolboxResource> Uses an existing Microsoft Foundry Toolbox during local runs and deployment.
public static class FoundryToolboxBuilderExtensions{ public static IResourceBuilder<FoundryToolboxResource> AsExisting( this IResourceBuilder<FoundryToolboxResource> builder) { // ... }}Parameters
builderIResourceBuilder<FoundryToolboxResource>The resource builder for the Toolbox.Returns
IResourceBuilder<FoundryToolboxResource>A reference to the ApplicationModel.IResourceBuilder`1 for chaining.Remarks
Existing mode validates that the remote Toolbox and optional pinned
FoundryToolboxResource.Version exist without resolving locally modeled tools or mutating the Toolbox. PublishAsExisting(IResourceBuilder<FoundryToolboxResource>)Section titled PublishAsExisting(IResourceBuilder<FoundryToolboxResource>)extensionIResourceBuilder<FoundryToolboxResource> Reconciles a Microsoft Foundry Toolbox during local runs and uses an existing Toolbox during deployment.
public static class FoundryToolboxBuilderExtensions{ public static IResourceBuilder<FoundryToolboxResource> PublishAsExisting( this IResourceBuilder<FoundryToolboxResource> builder) { // ... }}Parameters
builderIResourceBuilder<FoundryToolboxResource>The resource builder for the Toolbox.Returns
IResourceBuilder<FoundryToolboxResource>A reference to the ApplicationModel.IResourceBuilder`1 for chaining.Remarks
Existing mode validates that the remote Toolbox and optional pinned
FoundryToolboxResource.Version exist without resolving locally modeled tools or mutating the Toolbox. RunAsExisting(IResourceBuilder<FoundryToolboxResource>)Section titled RunAsExisting(IResourceBuilder<FoundryToolboxResource>)extensionIResourceBuilder<FoundryToolboxResource> Uses an existing Microsoft Foundry Toolbox during local runs and reconciles it during deployment.
public static class FoundryToolboxBuilderExtensions{ public static IResourceBuilder<FoundryToolboxResource> RunAsExisting( this IResourceBuilder<FoundryToolboxResource> builder) { // ... }}Parameters
builderIResourceBuilder<FoundryToolboxResource>The resource builder for the Toolbox.Returns
IResourceBuilder<FoundryToolboxResource>A reference to the ApplicationModel.IResourceBuilder`1 for chaining.Remarks
Existing mode validates that the remote Toolbox and optional pinned
FoundryToolboxResource.Version exist without resolving locally modeled tools or mutating the Toolbox. WithAISearchTool(IResourceBuilder<FoundryToolboxResource>, string, IResourceBuilder<AzureSearchResource>, string, string?)Section titled WithAISearchTool(IResourceBuilder<FoundryToolboxResource>, string, IResourceBuilder<AzureSearchResource>, string, string?)extensionIResourceBuilder<FoundryToolboxResource> Adds an Azure AI Search tool definition to the Toolbox.
public static class FoundryToolboxBuilderExtensions{ public static IResourceBuilder<FoundryToolboxResource> WithAISearchTool( this IResourceBuilder<FoundryToolboxResource> builder, string name, IResourceBuilder<AzureSearchResource> search, string indexName, string? description = null) { // ... }}Parameters
builderIResourceBuilder<FoundryToolboxResource>The resource builder for the Toolbox.namestringThe tool name.searchIResourceBuilder<AzureSearchResource>The Azure AI Search resource backing the tool.indexNamestringThe search index name.descriptionstring?optionalAn optional description of the Azure AI Search tool.Returns
IResourceBuilder<FoundryToolboxResource>A reference to the ApplicationModel.IResourceBuilder`1 for chaining.WithDescription(IResourceBuilder<FoundryToolboxResource>, string)Section titled WithDescription(IResourceBuilder<FoundryToolboxResource>, string)extensionIResourceBuilder<FoundryToolboxResource> Sets the description persisted with each Toolbox version.
public static class FoundryToolboxBuilderExtensions{ public static IResourceBuilder<FoundryToolboxResource> WithDescription( this IResourceBuilder<FoundryToolboxResource> builder, string description) { // ... }}Parameters
builderIResourceBuilder<FoundryToolboxResource>The resource builder for the Toolbox.descriptionstringThe Toolbox description.Returns
IResourceBuilder<FoundryToolboxResource>A reference to the ApplicationModel.IResourceBuilder`1 for chaining.WithMcpTool(IResourceBuilder<FoundryToolboxResource>, string, string, FoundryToolboxMcpToolOptions?)Section titled WithMcpTool(IResourceBuilder<FoundryToolboxResource>, string, string, FoundryToolboxMcpToolOptions?)extensionIResourceBuilder<FoundryToolboxResource> Adds an MCP tool definition to the Toolbox.
public static class FoundryToolboxBuilderExtensions{ public static IResourceBuilder<FoundryToolboxResource> WithMcpTool( this IResourceBuilder<FoundryToolboxResource> builder, string name, string endpoint, FoundryToolboxMcpToolOptions? options = null) { // ... }}Parameters
builderIResourceBuilder<FoundryToolboxResource>The resource builder for the Toolbox.namestringThe tool name.endpointstringThe MCP endpoint URI.optionsFoundryToolboxMcpToolOptions?optionalOptional MCP server metadata and approval policy.Returns
IResourceBuilder<FoundryToolboxResource>A reference to the ApplicationModel.IResourceBuilder`1 for chaining.WithMcpTool(IResourceBuilder<FoundryToolboxResource>, string, EndpointReference, FoundryToolboxMcpToolOptions?)Section titled WithMcpTool(IResourceBuilder<FoundryToolboxResource>, string, EndpointReference, FoundryToolboxMcpToolOptions?)extensionIResourceBuilder<FoundryToolboxResource> Adds an MCP tool definition to the Toolbox.
public static class FoundryToolboxBuilderExtensions{ public static IResourceBuilder<FoundryToolboxResource> WithMcpTool( this IResourceBuilder<FoundryToolboxResource> builder, string name, EndpointReference endpoint, FoundryToolboxMcpToolOptions? options = null) { // ... }}Parameters
builderIResourceBuilder<FoundryToolboxResource>The resource builder for the Toolbox.namestringThe tool name.endpointEndpointReferenceThe MCP endpoint.optionsFoundryToolboxMcpToolOptions?optionalOptional MCP server metadata and approval policy.Returns
IResourceBuilder<FoundryToolboxResource>A reference to the ApplicationModel.IResourceBuilder`1 for chaining.Remarks
During local development, the endpoint must resolve to a Foundry-reachable HTTPS URI, such as an anonymous development tunnel. A localhost endpoint cannot be reached by the Foundry data plane. Resource endpoints deployed with public HTTPS ingress can be referenced directly when using
aspire deploy. WithWebSearchTool(IResourceBuilder<FoundryToolboxResource>, string, string?)Section titled WithWebSearchTool(IResourceBuilder<FoundryToolboxResource>, string, string?)extensionIResourceBuilder<FoundryToolboxResource> Adds a web search tool definition to the Toolbox.
public static class FoundryToolboxBuilderExtensions{ public static IResourceBuilder<FoundryToolboxResource> WithWebSearchTool( this IResourceBuilder<FoundryToolboxResource> builder, string name = "web-search", string? description = null) { // ... }}Parameters
builderIResourceBuilder<FoundryToolboxResource>The resource builder for the Toolbox.namestringoptionalThe tool name.descriptionstring?optionalAn optional description of the web search tool.Returns
IResourceBuilder<FoundryToolboxResource>A reference to the ApplicationModel.IResourceBuilder`1 for chaining.