Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple deployments per cognitive service #3448

Merged
merged 3 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<PackageVersion Include="Microsoft.Azure.SignalR" Version="1.25.1" />
<PackageVersion Include="Microsoft.Extensions.Azure" Version="1.7.2" />
<!-- Azure Management SDK for .NET dependencies -->
<PackageVersion Include="Azure.Provisioning" Version="0.2.0-beta.1" />
<PackageVersion Include="Azure.Provisioning" Version="0.2.0-beta.2" />
<PackageVersion Include="Azure.Provisioning.AppConfiguration" Version="0.1.0-beta.1" />
<PackageVersion Include="Azure.Provisioning.ApplicationInsights" Version="0.1.0-beta.1" />
<PackageVersion Include="Azure.Provisioning.CognitiveServices" Version="0.1.0-beta.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public static IResourceBuilder<AzureOpenAIResource> AddAzureOpenAI(this IDistrib

var resource = (AzureOpenAIResource)construct.Resource;

CognitiveServicesAccountDeployment? dependency = null;

var cdkDeployments = new List<CognitiveServicesAccountDeployment>();
foreach (var deployment in resource.Deployments)
{
Expand All @@ -65,6 +67,17 @@ public static IResourceBuilder<AzureOpenAIResource> AddAzureOpenAI(this IDistrib
cdkDeployment.AssignProperty(x => x.Sku.Name, $"'{deployment.SkuName}'");
cdkDeployment.AssignProperty(x => x.Sku.Capacity, $"{deployment.SkuCapacity}");
cdkDeployments.Add(cdkDeployment);

// Subsequent deployments need an explicit dependency on the previous one
// to ensure they are not created in parallel. This is equivalent to @batchSize(1)
// which can't be defined with the CDK
Comment on lines +72 to +73
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is equivalent to @batchsize(1)
// which can't be defined with the CDK

When will this be available? That seems like the better long-term fix.

Copy link
Member

@mitchdenny mitchdenny Apr 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are waiting for this to merge and a build to be produced:

https://github.com/Azure/azure-sdk-for-net/pull/43285/files

@JoshLove-msft and @tg-msft can talk to timelines.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be shipping today

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, reacting ASAP

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When will this be available? That seems like the better long-term fix.

I think the question was not about the AddDependency being made public, but the support for @batchSize(1).


if (dependency != null)
{
cdkDeployment.AddDependency(dependency);
}

dependency = cdkDeployment;
}

var resourceBuilder = builder.CreateResourceBuilder(resource);
Expand Down
28 changes: 25 additions & 3 deletions tests/Aspire.Hosting.Tests/Azure/AzureBicepResourceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2249,14 +2249,17 @@ public async Task AddAzureOpenAI()
var openai = builder.AddAzureOpenAI("openai", (_, _, _, deployments) =>
{
aiDeployments = deployments;
}).AddDeployment(new("mymodel", "gpt-35-turbo", "0613", "Basic", 4));
})
.AddDeployment(new("mymodel", "gpt-35-turbo", "0613", "Basic", 4))
.AddDeployment(new("embedding-model", "text-embedding-ada-002", "2", "Basic", 4));

var manifest = await ManifestUtils.GetManifestWithBicep(openai.Resource);

Assert.NotNull(aiDeployments);
Assert.Collection(
aiDeployments,
deployment => Assert.Equal("mymodel", deployment.Properties.Name));
deployment => Assert.Equal("mymodel", deployment.Properties.Name),
deployment => Assert.Equal("embedding-model", deployment.Properties.Name));

var expectedManifest = """
{
Expand Down Expand Up @@ -2323,8 +2326,27 @@ param principalType string
}
}

output connectionString string = 'Endpoint=${cognitiveServicesAccount_wXAGTFUId.properties.endpoint}'
resource cognitiveServicesAccountDeployment_mdCAJJRlf 'Microsoft.CognitiveServices/accounts/deployments@2023-05-01' = {
parent: cognitiveServicesAccount_wXAGTFUId
dependsOn: [
cognitiveServicesAccountDeployment_5K9aRgiZP
]
name: 'embedding-model'
sku: {
name: 'Basic'
capacity: 4
}
properties: {
model: {
format: 'OpenAI'
name: 'text-embedding-ada-002'
version: '2'
}
}
}

output connectionString string = 'Endpoint=${cognitiveServicesAccount_wXAGTFUId.properties.endpoint}'

""";
output.WriteLine(manifest.BicepText);
Assert.Equal(expectedBicep, manifest.BicepText);
Expand Down