|
| 1 | +--- |
| 2 | +title: "Breaking change - AzureOpenAIDeployment obsolete" |
| 3 | +description: "Learn about the breaking change in .NET Aspire 9.2 where Azure OpenAI deployments are now modeled as .NET Aspire child resources." |
| 4 | +ms.date: 4/15/2025 |
| 5 | +ai-usage: ai-assisted |
| 6 | +ms.custom: https://github.com/dotnet/docs-aspire/issues/3059 |
| 7 | +--- |
| 8 | + |
| 9 | +# AzureOpenAIDeployment obsolete |
| 10 | + |
| 11 | +In .NET Aspire 9.2, Azure OpenAI deployments are modeled as .NET Aspire child resources instead of simple objects. This change aligns with the design of other [hosting integrations](../../fundamentals/integrations-overview.md#hosting-integrations) and enables referencing deployments using <xref:Aspire.Hosting.ResourceBuilderExtensions.WithReference*>. As a result, the previous APIs for adding deployments are now obsolete. |
| 12 | + |
| 13 | +## Version introduced |
| 14 | + |
| 15 | +.NET Aspire 9.2 |
| 16 | + |
| 17 | +## Previous behavior |
| 18 | + |
| 19 | +Previously, deployments were added as simple objects using the <xref:Aspire.Hosting.ApplicationModel.AzureOpenAIDeployment> class. For example: |
| 20 | + |
| 21 | +```csharp |
| 22 | +var builder = DistributedApplication.CreateBuilder(args); |
| 23 | + |
| 24 | +var openAI = builder.AddAzureOpenAI(openAIName); |
| 25 | + |
| 26 | +openAI.AddDeployment(new AzureOpenAIDeployment("chat", "gpt-4o-mini", "2024-07-18")) |
| 27 | + .AddDeployment(new AzureOpenAIDeployment("embedding", "text-embedding-3-small", "1")); |
| 28 | +``` |
| 29 | + |
| 30 | +## New behavior |
| 31 | + |
| 32 | +Deployments are modeled as .NET Aspire child resources and are added using the new overloads. For example, consider the following code: |
| 33 | + |
| 34 | +```csharp |
| 35 | +var builder = DistributedApplication.CreateBuilder(args); |
| 36 | + |
| 37 | +var openAI = builder.AddAzureOpenAI(openAIName); |
| 38 | + |
| 39 | +var chatModel = openAI.AddDeployment("chat", "gpt-4o-mini", "2024-07-18"); |
| 40 | +var embeddingModel = openAI.AddDeployment("embedding", "text-embedding-3-small", "1"); |
| 41 | +``` |
| 42 | + |
| 43 | +## Type of breaking change |
| 44 | + |
| 45 | +This is a [source incompatible](../categories.md#source-compatibility) change. |
| 46 | + |
| 47 | +## Reason for change |
| 48 | + |
| 49 | +Modeling deployments as Aspire resources allows them to be referenced by other resources via `.WithReference`. This design eliminates the need to hard-code model names in .NET applications and enables configuration-based deployment name resolution. It also ensures consistency with other hosting integrations. |
| 50 | + |
| 51 | +## Recommended action |
| 52 | + |
| 53 | +Update your code to use the new overloads for adding deployments. Replace calls to the obsolete APIs with the new pattern. For example: |
| 54 | + |
| 55 | +**Before:** |
| 56 | + |
| 57 | +```csharp |
| 58 | +openAI.AddDeployment(new AzureOpenAIDeployment("chat", "gpt-4o-mini", "2024-07-18")); |
| 59 | +``` |
| 60 | + |
| 61 | +**After:** |
| 62 | + |
| 63 | +```csharp |
| 64 | +var chatModel = openAI.AddDeployment("chat", "gpt-4o-mini", "2024-07-18"); |
| 65 | +``` |
| 66 | + |
| 67 | +## Affected APIs |
| 68 | + |
| 69 | +- <xref:Aspire.Hosting.AzureOpenAIExtensions.AddDeployment*> |
0 commit comments