-
Notifications
You must be signed in to change notification settings - Fork 909
Update Foundry hosted agent builder APIs #17545
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
Changes from all commits
9085ee7
8957ea8
3890b43
c821b38
f572c46
cae8e89
869dbab
bba95a0
f5cb7a2
ac68738
90fa06e
888b627
30430d9
4ef5764
c9f48bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| namespace Aspire.Hosting.Foundry; | ||
|
|
||
| // HostedAgentOptions exposes the subset of HostedAgentConfiguration that is meaningful to non-.NET | ||
| // app hosts. .NET callers should use the AsHostedAgent overload that takes Action<HostedAgentConfiguration> | ||
| // to access the full configuration surface (tools, content filters, container protocol versions, etc.). | ||
|
|
||
| /// <summary> | ||
| /// Options that control how a compute resource is deployed as a Microsoft Foundry hosted agent. | ||
| /// All properties are optional; unset properties fall back to the Foundry hosted agent defaults. | ||
| /// </summary> | ||
| [AspireDto] | ||
| internal sealed class HostedAgentOptions | ||
| { | ||
| /// <summary> | ||
| /// Human-readable description of the hosted agent surfaced in the Microsoft Foundry portal. | ||
| /// When not set, the hosted agent default description is used. | ||
| /// </summary> | ||
| public string? Description { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// CPU allocation for each hosted agent instance, in vCPU cores. Must be between 0.5 and 3.5 | ||
| /// in increments of 0.25. When not set, the hosted agent default CPU allocation is used. | ||
| /// </summary> | ||
| public decimal? Cpu { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Memory allocation for each hosted agent instance, in GiB. Must be between 1 and 7 in | ||
| /// increments of 0.5 and equal to twice the CPU value. When not set, the hosted agent | ||
| /// default memory allocation is used. | ||
| /// </summary> | ||
| public decimal? Memory { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Additional metadata key/value pairs to attach to the hosted agent definition. | ||
| /// Entries with the same key as an existing metadata entry overwrite it. | ||
| /// </summary> | ||
| public IDictionary<string, string> Metadata { get; init; } = new Dictionary<string, string>(); | ||
|
|
||
| /// <summary> | ||
| /// Environment variables to set on the hosted agent container at runtime. | ||
| /// Entries with the same key as an existing environment variable overwrite it. | ||
| /// </summary> | ||
| public IDictionary<string, string> EnvironmentVariables { get; init; } = new Dictionary<string, string>(); | ||
|
|
||
| internal void ApplyTo(HostedAgentConfiguration configuration) | ||
| { | ||
| if (Description is not null) | ||
| { | ||
| configuration.Description = Description; | ||
| } | ||
|
|
||
| // Cpu and Memory have a coupled invariant on HostedAgentConfiguration (Memory = Cpu * 2 with validation). | ||
| // Apply Cpu first so a subsequent Memory assignment can still override the derived value. | ||
| if (Cpu is { } cpu) | ||
| { | ||
| configuration.Cpu = cpu; | ||
| } | ||
|
|
||
| if (Memory is { } memory) | ||
| { | ||
| configuration.Memory = memory; | ||
| } | ||
|
|
||
| foreach (var kvp in Metadata) | ||
| { | ||
| configuration.Metadata[kvp.Key] = kvp.Value; | ||
| } | ||
|
|
||
| foreach (var kvp in EnvironmentVariables) | ||
| { | ||
| configuration.EnvironmentVariables[kvp.Key] = kvp.Value; | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -96,6 +96,10 @@ public static ApplicationModel.IResourceBuilder<T> WithRoleAssignments<T>(this A | |
|
|
||
| public static partial class HostedAgentResourceBuilderExtensions | ||
| { | ||
| [AspireExport] | ||
| public static ApplicationModel.IResourceBuilder<T> AsHostedAgent<T>(this ApplicationModel.IResourceBuilder<T> builder) | ||
| where T : ApplicationModel.IResourceWithEndpoints, ApplicationModel.IResourceWithEnvironment, ApplicationModel.IComputeResource { throw null; } | ||
|
|
||
| [AspireExport("withComputeEnvironmentExecutable", MethodName = "withComputeEnvironment")] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should have been renamed to prevent a conflict with the standard one
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was changed, this is the api file ... I don't think this should have been merged @davidfowl ? |
||
| public static ApplicationModel.IResourceBuilder<T> WithComputeEnvironment<T>(this ApplicationModel.IResourceBuilder<T> builder, ApplicationModel.IResourceBuilder<Foundry.AzureCognitiveServicesProjectResource>? project = null, System.Action<Foundry.HostedAgentConfiguration>? configure = null) | ||
| where T : ApplicationModel.IResourceWithEndpoints, ApplicationModel.IResourceWithEnvironment, ApplicationModel.IComputeResource { throw null; } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why this line is new, it should be removed actually, or at least not added, the method doesn't exist anymore. Is that a merge conflict resolution error?