Skip to main content
net8.0

Azure AI Foundry resource types for .NET Aspire.

Published
Aug 12, 2025
1y ago
Total Downloads
152.6K
152,648

Deprecated Package Version

Reason: Other, Legacy

This version is out of support and is no longer maintained. Please upgrade to the latest version. See our support policy for details: https://aka.ms/dotnet/aspire/support

Install

dotnet add package Aspire.Hosting.Azure.AIFoundry --version 9.4.1-preview.1.25408.4
ProductVersions
.NET
net8.0

README

Aspire.Hosting.Azure.AIFoundry library

Provides extension methods and resource definitions for a .NET Aspire AppHost to configure Azure AI Foundry.

Getting started

Prerequisites

Install the package

In your AppHost project, install the .NET Aspire Azure AI Foundry Hosting library with NuGet:

dotnet add package Aspire.Hosting.Azure.AIFoundry

Configure Azure Provisioning for local development

Adding Azure resources to the .NET 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>"
    }
}

Usage example

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.

Inference client usage
builder.AddAzureChatCompletionsClient("chat")
       .AddChatClient();
OpenAI client usage
builder.AddOpenAIClient("chat")
       .AddChatClient();

Emulator usage

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.

Additional documentation

Feedback & contributing

https://github.com/dotnet/aspire

Changes from Previous Version

No structural changes between v9.4.0-preview.1.25378.8 and v9.4.1-preview.1.25408.4.

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

This version is marked prerelease. Validate its API and upgrade path before production use.NuGet marks this package as deprecated. Review the publisher's migration guidance before adopting it.Compatibility metadata lists 1 target framework; confirm the exact target used by your application.The published metadata declares 34 direct dependency entries across framework groups. Inspect the resolved dependency graph for your target framework.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.