![]() |
VOOZH | about |
dotnet add package Aspire.Hosting.Azure.AIFoundry --version 13.1.3-preview.1.26166.8
NuGet\Install-Package Aspire.Hosting.Azure.AIFoundry -Version 13.1.3-preview.1.26166.8
<PackageReference Include="Aspire.Hosting.Azure.AIFoundry" Version="13.1.3-preview.1.26166.8" />
<PackageVersion Include="Aspire.Hosting.Azure.AIFoundry" Version="13.1.3-preview.1.26166.8" />Directory.Packages.props
<PackageReference Include="Aspire.Hosting.Azure.AIFoundry" />Project file
paket add Aspire.Hosting.Azure.AIFoundry --version 13.1.3-preview.1.26166.8
#r "nuget: Aspire.Hosting.Azure.AIFoundry, 13.1.3-preview.1.26166.8"
#:package Aspire.Hosting.Azure.AIFoundry@13.1.3-preview.1.26166.8
#addin nuget:?package=Aspire.Hosting.Azure.AIFoundry&version=13.1.3-preview.1.26166.8&prereleaseInstall as a Cake Addin
#tool nuget:?package=Aspire.Hosting.Azure.AIFoundry&version=13.1.3-preview.1.26166.8&prereleaseInstall as a Cake Tool
Provides extension methods and resource definitions for an Aspire AppHost to configure Azure AI Foundry.
In your AppHost project, install the Aspire Azure AI Foundry Hosting library with NuGet:
dotnet add package Aspire.Hosting.Azure.AIFoundry
Adding Azure resources to the Aspire application 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 .NET configuration. Set these values in user secrets in order to allow resources to be configured automatically.
{
"Azure": {
"SubscriptionId": "<your subscription id>",
"ResourceGroupPrefix": "<prefix for the resource group>",
"Location": "<azure location>"
}
}
Then, in the AppHost.cs file of AppHost, add an Azure AI Foundry deployment and consume the connection using the following methods:
var chat = builder.AddAzureAIFoundry("foundry")
.AddDeployment("chat", "Phi-4", "1", "Microsoft");
var myService = builder.AddProject<Projects.MyService>()
.WithReference(chat).WaitFor(chat);
The WithReference method passes that connection information into a connection string named chat in the MyService project.
In the Program.cs file of MyService, the connection can be consumed using a client library like Aspire.Azure.AI.Inference or Aspire.OpenAI if the model is compatible with the OpenAI API:
Note: The format parameter of the AddDeployment() method can be found in the Azure AI Foundry portal in the details
page of the model, right after the Quick facts text.
builder.AddAzureChatCompletionsClient("chat")
.AddChatClient();
builder.AddOpenAIClient("chat")
.AddChatClient();
Aspire supports the usage of the Foundry Local. Add the following to your AppHost project:
// AppHost
var chat = builder.AddAzureAIFoundry("foundry")
.RunAsFoundryLocal()
.AddDeployment("chat", "phi-3.5-mini", "1", "Microsoft");
When the AppHost starts up the local foundry service also be started.
This requires the local machine to have the Foundry Local installed and running.
When you reference Azure AI Foundry resources using WithReference, the following connection properties are made available to the consuming project:
The Azure AI Foundry resource exposes the following connection properties:
| Property Name | Description |
|---|---|
Uri |
The endpoint URI for the Azure AI Foundry resource (e.g., 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) |
Key |
The API key when using Foundry Local resource, e.g., OPENAI_API_KEY |
The Azure AI Foundry deployment resource inherits all properties from its parent Azure AI 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 |
Note: The property named ModelName refers to the deployment name when targeting Azure AI Foundry, but to the model identifier when running Foundry Local.
Aspire exposes each property as an environment variable named [RESOURCE]_[PROPERTY]. For instance, the Uri property of a resource called chat becomes CHAT_URI.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.