Aspire.Hosting.Foundry
13.5.3-preview.1.26425.3
Prefix Reserved
dotnet add package Aspire.Hosting.Foundry --version 13.5.3-preview.1.26425.3
NuGet\Install-Package Aspire.Hosting.Foundry -Version 13.5.3-preview.1.26425.3
<PackageReference Include="Aspire.Hosting.Foundry" Version="13.5.3-preview.1.26425.3" />
<PackageVersion Include="Aspire.Hosting.Foundry" Version="13.5.3-preview.1.26425.3" />
<PackageReference Include="Aspire.Hosting.Foundry" />
paket add Aspire.Hosting.Foundry --version 13.5.3-preview.1.26425.3
#r "nuget: Aspire.Hosting.Foundry, 13.5.3-preview.1.26425.3"
#:package Aspire.Hosting.Foundry@13.5.3-preview.1.26425.3
#addin nuget:?package=Aspire.Hosting.Foundry&version=13.5.3-preview.1.26425.3&prerelease
#tool nuget:?package=Aspire.Hosting.Foundry&version=13.5.3-preview.1.26425.3&prerelease
Microsoft Foundry hosting integration
Use this integration to model, configure, and orchestrate Microsoft Foundry in an Aspire solution.
Getting started
Prerequisites
- Azure subscription - create one for free
Add the integration
From your AppHost directory, add the Aspire.Hosting.Foundry integration with the Aspire CLI:
aspire add Aspire.Hosting.Foundry
Configure Azure Provisioning for local development
Adding Azure resources to the AppHost model will automatically enable development-time provisioning
for Azure resources so that you don't need to configure them manually. Provisioning requires a number of settings
to be available via AppHost configuration. From your AppHost directory, set these values with aspire secret set:
aspire secret set Azure:SubscriptionId "<your subscription id>"
aspire secret set Azure:ResourceGroupPrefix "<prefix for the resource group>"
aspire secret set Azure:Location "<azure location>"
Usage example
In the AppHost, add a Microsoft Foundry deployment and reference it from another resource with either C# or TypeScript:
C#
var chat = builder.AddFoundry("foundry")
.AddDeployment("chat", "Phi-4", "1", "Microsoft");
var myService = builder.AddProject<Projects.MyService>()
.WithReference(chat);
TypeScript
const chat = await builder.addFoundry("foundry")
.addDeployment("chat", "Phi-4", "1", "Microsoft");
const myService = await builder.addNodeApp("myService", "../my-service", "server.js")
.withReference(chat);
Connection Properties
When you reference Microsoft Foundry resources using WithReference, the following connection properties are made available to the consuming project:
Microsoft Foundry resource
The Microsoft Foundry resource exposes the following connection properties:
| Property Name | Description |
|---|---|
Uri |
The endpoint URI for the Microsoft Foundry resource, with the format https://<resource_name>.services.ai.azure.com/ or the emulator service URI when running Foundry Local (e.g., http://127.0.0.1:61799/v1) |
AIInferenceUri |
The AI inference endpoint URI, with the format https://<resource_name>.services.ai.azure.com/models when targeting Azure or the emulator service URI when running Foundry Local (e.g., http://127.0.0.1:61799/v1) |
Key |
The API key when using Foundry Local |
See Migrate from Azure AI Inference to Azure OpenAI in Azure AI Foundry Models for guidance on which URI to use based on the SDK used by your application.
Microsoft Foundry deployment
The Microsoft Foundry deployment resource inherits all properties from its parent Microsoft Foundry resource and adds:
| Property Name | Description |
|---|---|
ModelName |
The deployment name when targeting Azure or model identifier when running Foundry Local, e.g., Phi-4, my-chat |
Format |
The deployment format, e.g., OpenAI, Microsoft, xAi, Deepseek |
Version |
The deployment version, e.g., 1, 2025-08-07 |
Microsoft Foundry project
The Microsoft Foundry project resource exposes the following connection properties:
| Property Name | Description |
|---|---|
Uri |
The project endpoint URI, with the format https://<account>.services.ai.azure.com/api/projects/<project> |
ConnectionString |
The connection string, with the format Endpoint=<uri> |
ApplicationInsightsConnectionString |
The Application Insights connection string for telemetry |
Aspire exposes each property as an environment variable named [RESOURCE]_[PROPERTY]. For instance, the Uri property of a resource called chat becomes CHAT_URI.
Microsoft Foundry project usage
You can create a Microsoft Foundry project resource to organize agents and model deployments:
var foundry = builder.AddFoundry("foundry");
var project = foundry.AddProject("my-project");
var chat = project.AddModelDeployment("chat", "gpt-4", "1.0", "OpenAI");
var myService = builder.AddPythonApp("agent", "./app", "main:app")
.WithReference(project);
The project can also be configured with additional Azure resources:
var appInsights = builder.AddAzureApplicationInsights("ai");
var keyVault = builder.AddAzureKeyVault("kv");
var project = foundry.AddProject("my-project")
.WithAppInsights(appInsights)
.WithKeyVault(keyVault);
Hosted agent usage
To deploy a containerized application as a hosted agent in Microsoft Foundry:
var foundry = builder.AddFoundry("foundry");
var project = foundry.AddProject("my-project");
builder.AddPythonApp("agent", "./app", "main:app")
.AsHostedAgent(project);
In run mode, the agent runs locally with health check endpoints and OpenTelemetry instrumentation. In publish mode, the agent is deployed as a hosted agent in Microsoft Foundry.
Prompt agent usage
Prompt agents are declarative agents defined by a model, instructions, and tools. They are always deployed to Azure Foundry — even during local development (aspire run) — and local services communicate with the cloud-provisioned agent.
Tools are project-level resources that can be reused across multiple agents:
var foundry = builder.AddFoundry("foundry");
var project = foundry.AddProject("my-project");
var chat = project.AddModelDeployment("gpt41", FoundryModel.OpenAI.Gpt41);
// Create tools at the project level
var codeInterp = project.AddCodeInterpreterTool("code-interp");
var webSearch = project.AddWebSearchTool("web-search");
// Add agent with tools
var agent = project.AddPromptAgent(chat, "joker-agent",
instructions: "You are good at telling jokes.")
.WithTool(codeInterp)
.WithTool(webSearch);
builder.AddPythonApp("app", "./app", "main:app")
.WithReference(agent);
Available tools
Prompt agents support several tool types, all created as project-level resources:
| Tool | Extension Method | Description |
|---|---|---|
| Code Interpreter | project.AddCodeInterpreterTool(name) |
Runs Python code in a sandbox |
| File Search | project.AddFileSearchTool(name, vectorStoreIds) |
Searches uploaded documents via vector search |
| Web Search | project.AddWebSearchTool(name) |
Retrieves real-time web information |
| Azure AI Search | project.AddAISearchTool(name).WithReference(search) |
Grounds responses using Azure AI Search indexes |
| Bing Grounding | project.AddBingGroundingTool(name).WithReference(conn) |
Grounds responses using Bing Search |
| SharePoint | project.AddSharePointTool(name, connectionIds) |
Searches SharePoint data |
| Microsoft Fabric | project.AddFabricTool(name, connectionIds) |
Queries data through Fabric data agents |
| Azure Functions | project.AddAzureFunctionTool(name, ...) |
Invokes serverless Azure Functions |
| Function Calling | project.AddFunctionTool(name, funcName, params) |
Calls application-defined functions |
| Image Generation | project.AddImageGenerationTool(name) |
Generates and edits images (preview) |
| Computer Use | project.AddComputerUseTool(name, w, h) |
Interacts with a computer desktop (preview) |
Azure AI Search tool example
var search = builder.AddAzureSearch("search");
var aiSearch = project.AddAISearchTool("search-tool").WithReference(search);
var agent = project.AddPromptAgent(chat, "research-agent")
.WithTool(aiSearch);
Bing Grounding tool example
Note: The Bing Search resource (
Microsoft.Bing/accounts) cannot be provisioned via Bicep or ARM templates. You must create it manually in the Azure portal. Once created, Aspire can automatically provision the Foundry project connection for you.
The simplest approach is to pass the Bing resource ID directly — Aspire will create the connection with the correct authentication and metadata:
var bingResourceId = "/subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.Bing/accounts/{name}";
var bing = project.AddBingGroundingTool("bing-tool").WithReference(bingResourceId);
var agent = project.AddPromptAgent(chat, "news-agent")
.WithTool(bing);
Alternatively, you can create the connection yourself for full control:
var bingConnection = project.AddBingGroundingConnection("bing-conn", bingResourceId);
var bing = project.AddBingGroundingTool("bing-tool").WithReference(bingConnection);
Tool reuse across agents
Tools are project-level resources, so they can be shared across multiple agents:
var codeInterp = project.AddCodeInterpreterTool("code-interp");
var webSearch = project.AddWebSearchTool("web-search");
var agent1 = project.AddPromptAgent(chat, "agent-1").WithTool(codeInterp).WithTool(webSearch);
var agent2 = project.AddPromptAgent(chat, "agent-2").WithTool(codeInterp);
Additional documentation
- https://aspire.dev/integrations/gallery/
- https://aspire.dev/integrations/cloud/azure/azure-ai-foundry/azure-ai-foundry-host/
- https://learn.microsoft.com/azure/ai-foundry/what-is-azure-ai-foundry
- https://learn.microsoft.com/azure/ai-foundry/foundry-local/
Feedback & contributing
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Aspire.Hosting.Azure (>= 13.5.3)
- Aspire.Hosting.Azure.ApplicationInsights (>= 13.5.3)
- Aspire.Hosting.Azure.ContainerRegistry (>= 13.5.3)
- Aspire.Hosting.Azure.CosmosDB (>= 13.5.3)
- Aspire.Hosting.Azure.Search (>= 13.5.3)
- Aspire.Hosting.Azure.Storage (>= 13.5.3)
- AspNetCore.HealthChecks.Azure.Storage.Blobs (>= 9.0.0)
- AspNetCore.HealthChecks.Azure.Storage.Queues (>= 9.0.0)
- AspNetCore.HealthChecks.CosmosDb (>= 9.0.0)
- AspNetCore.HealthChecks.Uris (>= 9.0.0)
- Azure.AI.Projects (>= 2.1.0-beta.1)
- Azure.Core (>= 1.57.0)
- Azure.Identity (>= 1.21.0)
- Azure.Provisioning (>= 1.5.0)
- Azure.Provisioning.ApplicationInsights (>= 1.1.0)
- Azure.Provisioning.CognitiveServices (>= 1.2.0)
- Azure.Provisioning.ContainerRegistry (>= 1.1.0)
- Azure.Provisioning.CosmosDB (>= 1.0.0)
- Azure.Provisioning.KeyVault (>= 1.1.0)
- Azure.Provisioning.OperationalInsights (>= 1.1.0)
- Azure.Provisioning.Search (>= 1.0.0)
- Azure.Provisioning.Storage (>= 1.1.2)
- Azure.ResourceManager.Authorization (>= 1.1.6)
- Azure.ResourceManager.KeyVault (>= 1.4.0)
- Azure.ResourceManager.Resources (>= 1.11.2)
- Azure.Security.KeyVault.Secrets (>= 4.11.0)
- Azure.Storage.Blobs (>= 12.28.0)
- Azure.Storage.Files.DataLake (>= 12.26.0)
- Azure.Storage.Queues (>= 12.26.0)
- Google.Protobuf (>= 3.34.1)
- Grpc.AspNetCore (>= 2.80.0)
- Grpc.Net.ClientFactory (>= 2.80.0)
- Grpc.Tools (>= 2.80.0)
- Humanizer.Core (>= 3.0.10)
- JsonPatch.Net (>= 5.0.2)
- KubernetesClient (>= 19.0.2)
- Microsoft.AI.Foundry.Local (>= 1.1.0)
- Microsoft.Azure.Cosmos (>= 3.61.0)
- Microsoft.Bcl.Memory (>= 10.0.11)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.11)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.11)
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 10.0.11)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.11)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 8.0.30)
- Microsoft.Extensions.FileSystemGlobbing (>= 10.0.11)
- Microsoft.Extensions.Hosting (>= 10.0.11)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.11)
- Microsoft.Extensions.Http (>= 10.0.11)
- Microsoft.Extensions.Logging (>= 10.0.11)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.11)
- Microsoft.Extensions.Options (>= 10.0.11)
- Microsoft.Extensions.Primitives (>= 10.0.11)
- ModelContextProtocol (>= 1.3.0)
- NCrontab.Signed (>= 3.4.0)
- Newtonsoft.Json (>= 13.0.4)
- OpenAI (>= 2.12.0)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.15.3)
- OpenTelemetry.Extensions.Hosting (>= 1.15.3)
- Polly.Core (>= 8.6.6)
- Semver (>= 3.0.0)
- StreamJsonRpc (>= 2.25.29)
- System.IO.Hashing (>= 10.0.8)
- System.Text.Json (>= 10.0.11)
- YamlDotNet (>= 16.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 13.5.3-preview.1.26425.3 | 1,724 | 8/25/2026 |
| 13.5.2-preview.1.26421.6 | 2,164 | 8/21/2026 |
| 13.5.1-preview.1.26420.4 | 514 | 8/20/2026 |
| 13.5.0-preview.1.26417.10 | 260 | 8/18/2026 |
| 13.4.6-preview.1.26319.6 | 18,518 | 6/19/2026 |
| 13.4.5-preview.1.26316.12 | 415 | 6/17/2026 |
| 13.4.4-preview.1.26314.3 | 337 | 6/15/2026 |
| 13.4.3-preview.1.26305.13 | 4,008 | 6/8/2026 |
| 13.4.2-preview.1.26303.6 | 3,851 | 6/3/2026 |
| 13.4.1-preview.1.26303.3 | 80 | 6/3/2026 |
| 13.4.0-preview.1.26281.18 | 276 | 6/1/2026 |
| 13.3.5-preview.1.26270.6 | 1,319 | 5/21/2026 |
| 13.3.4-preview.1.26268.8 | 383 | 5/19/2026 |
| 13.3.3-preview.1.26264.13 | 873 | 5/15/2026 |
| 13.3.2-preview.1.26263.11 | 249 | 5/14/2026 |
| 13.3.1-preview.1.26261.7 | 1,234 | 5/12/2026 |
| 13.3.0-preview.1.26256.5 | 626 | 5/7/2026 |
| 13.2.4-preview.1.26224.4 | 1,725 | 4/24/2026 |
| 13.2.3-preview.1.26217.6 | 887 | 4/21/2026 |
| 13.2.2-preview.1.26207.2 | 4,898 | 4/8/2026 |