diff --git a/src/frontend/src/content/docs/integrations/cloud/azure/azure-ai-foundry/azure-ai-foundry-host.mdx b/src/frontend/src/content/docs/integrations/cloud/azure/azure-ai-foundry/azure-ai-foundry-host.mdx index b1cd7c297..e2bcff7eb 100644 --- a/src/frontend/src/content/docs/integrations/cloud/azure/azure-ai-foundry/azure-ai-foundry-host.mdx +++ b/src/frontend/src/content/docs/integrations/cloud/azure/azure-ai-foundry/azure-ai-foundry-host.mdx @@ -347,11 +347,11 @@ await foundry -`AddProject` creates a default Azure Container Registry for hosted agents. Use `WithContainerRegistry` when you want to point the project at a different registry. +`AddProject` creates a default Azure Container Registry for hosted agents only in publish mode (when deploying to Azure). In local run mode, no default registry is created. Use `WithContainerRegistry` when you want to point the project at a specific registry. -## Publish a hosted agent to Azure AI Foundry +## Add a hosted agent to Azure AI Foundry -Use `PublishAsHostedAgent` in C# or `withComputeEnvironment` in TypeScript to publish an executable or containerized app as a hosted agent in a Foundry project: +Use `AsHostedAgent` in C# or `asHostedAgent` in TypeScript to configure an executable or containerized app as a hosted agent in a Foundry project: @@ -366,13 +366,13 @@ var chat = project.AddModelDeployment("chat", FoundryModel.OpenAI.Gpt5Mini); builder.AddPythonApp("agent-python", "..\\agent", "main:app") .WithReference(project) .WithReference(chat) - .PublishAsHostedAgent(project); + .AsHostedAgent(project); builder.AddProject("agent-dotnet") .WithHttpEndpoint(targetPort: 9000) .WithReference(project) .WithReference(chat) - .PublishAsHostedAgent(project); + .AsHostedAgent(project); builder.Build().Run(); ``` @@ -397,14 +397,14 @@ await builder .addPythonApp('agent-python', '../agent', 'main:app') .withReference(project) .withReference(chat) - .withComputeEnvironment({ project }); + .asHostedAgent(project); await builder .addProject('agent-dotnet', '../Agent/Agent.csproj') .withHttpEndpoint({ targetPort: 9000 }) .withReference(project) .withReference(chat) - .withComputeEnvironment({ project }); + .asHostedAgent(project); await builder.build().run(); ``` @@ -412,7 +412,7 @@ await builder.build().run(); -In run mode, the hosted-agent configuration configures a local `http` endpoint for the agent. Aspire first checks whether the resource already has an endpoint named `http`. If that endpoint has a target port, Aspire preserves it. If there is no existing `http` target port, Aspire defaults to `8088`. +In run mode, `AsHostedAgent(...)` configures a local `http` endpoint for the agent. Aspire first checks whether the resource already has an endpoint named `http`. If that endpoint has a target port, Aspire preserves it. If there is no existing `http` target port, Aspire defaults to `8088`. Aspire also injects the selected port as `DEFAULT_AD_PORT`, so hosted-agent apps can bind to the right port: @@ -421,7 +421,7 @@ var port = Environment.GetEnvironmentVariable("DEFAULT_AD_PORT") ?? "8088"; builder.WebHost.UseUrls($"http://+:{port}"); ``` -If your hosted agent listens on a different port, declare the endpoint before configuring the resource as a hosted agent: +If your hosted agent listens on a different port, declare the endpoint before calling `AsHostedAgent(...)`: @@ -432,7 +432,7 @@ var dotnetWeatherAgent = builder.AddProject("weath .WithReference(project).WaitFor(project) .WithReference(chat).WaitFor(chat); -dotnetWeatherAgent.PublishAsHostedAgent(project); +dotnetWeatherAgent.AsHostedAgent(project); ``` @@ -450,19 +450,19 @@ const dotnetWeatherAgent = await builder .withReference(chat) .waitFor(chat); -await dotnetWeatherAgent.withComputeEnvironment({ project }); +await dotnetWeatherAgent.asHostedAgent(project); ``` -In run mode, Aspire also adds dashboard URLs for `/responses`, `/liveness`, and `/readiness`, configures `/liveness` as an HTTP health check, adds a dashboard command for sending a message to `/responses`, and enables OpenTelemetry environment variables for agent instrumentation. +In run mode, Aspire also opens the agent's dashboard URL at the selected protocol path, defaults that path to `/responses`, adds a dashboard command for sending a message to the selected path, and enables OpenTelemetry environment variables for agent instrumentation. For .NET hosted agents, add your Service Defaults project reference and call `builder.AddServiceDefaults()` in the hosted-agent app so logs, metrics, traces, HTTP instrumentation, and OTLP export flow into the Aspire dashboard. Then enable telemetry on the Foundry Responses chat client that backs the Microsoft Agent Framework (MAF) agent. In publish mode, Aspire creates an `AzureHostedAgentResource` and publishes the container to the project-associated registry. -If you omit the `project` argument, Aspire uses an existing Foundry project from the app model or creates one automatically. +For C# AppHosts, the parameterless `AsHostedAgent()` overload reuses an existing Foundry project from the app model or creates one automatically. TypeScript AppHosts pass the project resource explicitly. ### Add and publish a prompt agent @@ -539,7 +539,7 @@ Prompt agents are deployed to Azure AI Foundry even during local development. Lo ## Invoke agents from the Aspire dashboard -Aspire also makes the declared agents easy to try from the dashboard. Prompt agents get a **Send Message** command from `AddPromptAgent(...)`. Hosted agents published with `PublishAsHostedAgent(...)` get a highlighted **Send Message** command that posts to the local `/responses` endpoint, plus dashboard links for `/responses`, `/liveness`, and `/readiness`. +Aspire also makes the declared agents easy to try from the dashboard. Prompt agents get a **Send Message** command from `AddPromptAgent(...)`. Hosted agents configured with `AsHostedAgent(...)` get a highlighted **Send Message** command that posts to the selected protocol path, which defaults to the local `/responses` endpoint. Promise): IResourceWithEndpoints", + "signature": "asHostedAgent(project: AzureCognitiveServicesProjectResource, options?: HostedAgentOptions): IResourceWithEndpoints", "parameters": [ { "name": "project", - "type": "AzureCognitiveServicesProjectResource", - "isOptional": true + "type": "AzureCognitiveServicesProjectResource" }, { - "name": "configure", - "type": "callback", - "isOptional": true, - "isCallback": true, - "callbackSignature": "(obj: HostedAgentConfiguration) => Promise" + "name": "options", + "type": "HostedAgentOptions", + "isOptional": true } ], "returnType": "IResourceWithEndpoints", diff --git a/src/frontend/src/data/twoslash/aspire.d.ts b/src/frontend/src/data/twoslash/aspire.d.ts index 824c7c3b1..8fd43a738 100644 --- a/src/frontend/src/data/twoslash/aspire.d.ts +++ b/src/frontend/src/data/twoslash/aspire.d.ts @@ -10918,15 +10918,10 @@ export interface AzureCosmosDBDatabaseResource { // augments handle type AzureCosmosDBEmulatorResource with extension methods export interface AzureCosmosDBEmulatorResource { /** - * Configures the resource to run as a hosted agent in Microsoft Foundry. If a project resource is not provided, the method will attempt to find an existing Microsoft Foundry project resource in the application model. If none exists, a new project resource (and its parent account resource) will be created automatically. + * Configures the resource to run and publish as a hosted agent in Microsoft Foundry, targeting the specified Foundry project. */ - withComputeEnvironment(options?: { project?: AzureCognitiveServicesProjectResource; configure?: (obj: HostedAgentConfiguration) => Promise }): this; - /** - * Configures the resource to run as a hosted agent in Microsoft Foundry. If a project resource is not provided, the method will attempt to find an existing Microsoft Foundry project resource in the application model. If none exists, a new project resource (and its parent account resource) will be created automatically. - */ - - withComputeEnvironment(project?: AzureCognitiveServicesProjectResource, configure?: (obj: HostedAgentConfiguration) => Promise): this; + asHostedAgent(project: AzureCognitiveServicesProjectResource, options?: HostedAgentOptions): IResourceWithEndpoints; /** * Assigns the specified roles to the given resource, granting it the necessary permissions on the target Microsoft Foundry resource. This replaces the default role assignments for the resource. */ @@ -10937,15 +10932,10 @@ export interface AzureCosmosDBEmulatorResource { // augments handle type AzureCosmosDBResource with extension methods export interface AzureCosmosDBResource { /** - * Configures the resource to run as a hosted agent in Microsoft Foundry. If a project resource is not provided, the method will attempt to find an existing Microsoft Foundry project resource in the application model. If none exists, a new project resource (and its parent account resource) will be created automatically. + * Configures the resource to run and publish as a hosted agent in Microsoft Foundry, targeting the specified Foundry project. */ - withComputeEnvironment(options?: { project?: AzureCognitiveServicesProjectResource; configure?: (obj: HostedAgentConfiguration) => Promise }): this; - /** - * Configures the resource to run as a hosted agent in Microsoft Foundry. If a project resource is not provided, the method will attempt to find an existing Microsoft Foundry project resource in the application model. If none exists, a new project resource (and its parent account resource) will be created automatically. - */ - - withComputeEnvironment(project?: AzureCognitiveServicesProjectResource, configure?: (obj: HostedAgentConfiguration) => Promise): this; + asHostedAgent(project: AzureCognitiveServicesProjectResource, options?: HostedAgentOptions): IResourceWithEndpoints; /** * Assigns the specified roles to the given resource, granting it the necessary permissions on the target Microsoft Foundry resource. This replaces the default role assignments for the resource. */ @@ -11123,15 +11113,10 @@ export interface AzureKeyVaultResource { withKeyVaultRoleAssignments(target: AzureKeyVaultResource, roles: AzureKeyVaultRole[]): this; /** - * Configures the resource to run as a hosted agent in Microsoft Foundry. If a project resource is not provided, the method will attempt to find an existing Microsoft Foundry project resource in the application model. If none exists, a new project resource (and its parent account resource) will be created automatically. - */ - - withComputeEnvironment(options?: { project?: AzureCognitiveServicesProjectResource; configure?: (obj: HostedAgentConfiguration) => Promise }): this; - /** - * Configures the resource to run as a hosted agent in Microsoft Foundry. If a project resource is not provided, the method will attempt to find an existing Microsoft Foundry project resource in the application model. If none exists, a new project resource (and its parent account resource) will be created automatically. + * Configures the resource to run and publish as a hosted agent in Microsoft Foundry, targeting the specified Foundry project. */ - withComputeEnvironment(project?: AzureCognitiveServicesProjectResource, configure?: (obj: HostedAgentConfiguration) => Promise): this; + asHostedAgent(project: AzureCognitiveServicesProjectResource, options?: HostedAgentOptions): IResourceWithEndpoints; /** * Assigns the specified roles to the given resource, granting it the necessary permissions on the target Microsoft Foundry resource. This replaces the default role assignments for the resource. */ @@ -11521,15 +11506,10 @@ export interface AzureStorageEmulatorResource { withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): this; /** - * Configures the resource to run as a hosted agent in Microsoft Foundry. If a project resource is not provided, the method will attempt to find an existing Microsoft Foundry project resource in the application model. If none exists, a new project resource (and its parent account resource) will be created automatically. + * Configures the resource to run and publish as a hosted agent in Microsoft Foundry, targeting the specified Foundry project. */ - withComputeEnvironment(options?: { project?: AzureCognitiveServicesProjectResource; configure?: (obj: HostedAgentConfiguration) => Promise }): this; - /** - * Configures the resource to run as a hosted agent in Microsoft Foundry. If a project resource is not provided, the method will attempt to find an existing Microsoft Foundry project resource in the application model. If none exists, a new project resource (and its parent account resource) will be created automatically. - */ - - withComputeEnvironment(project?: AzureCognitiveServicesProjectResource, configure?: (obj: HostedAgentConfiguration) => Promise): this; + asHostedAgent(project: AzureCognitiveServicesProjectResource, options?: HostedAgentOptions): IResourceWithEndpoints; /** * Assigns the specified roles to the given resource, granting it the necessary permissions on the target Microsoft Foundry resource. This replaces the default role assignments for the resource. */ @@ -11550,15 +11530,10 @@ export interface AzureStorageResource { withStorageRoleAssignments(target: AzureStorageResource, roles: AzureStorageRole[]): this; /** - * Configures the resource to run as a hosted agent in Microsoft Foundry. If a project resource is not provided, the method will attempt to find an existing Microsoft Foundry project resource in the application model. If none exists, a new project resource (and its parent account resource) will be created automatically. + * Configures the resource to run and publish as a hosted agent in Microsoft Foundry, targeting the specified Foundry project. */ - withComputeEnvironment(options?: { project?: AzureCognitiveServicesProjectResource; configure?: (obj: HostedAgentConfiguration) => Promise }): this; - /** - * Configures the resource to run as a hosted agent in Microsoft Foundry. If a project resource is not provided, the method will attempt to find an existing Microsoft Foundry project resource in the application model. If none exists, a new project resource (and its parent account resource) will be created automatically. - */ - - withComputeEnvironment(project?: AzureCognitiveServicesProjectResource, configure?: (obj: HostedAgentConfiguration) => Promise): this; + asHostedAgent(project: AzureCognitiveServicesProjectResource, options?: HostedAgentOptions): IResourceWithEndpoints; /** * Assigns the specified roles to the given resource, granting it the necessary permissions on the target Microsoft Foundry resource. This replaces the default role assignments for the resource. */ @@ -12778,15 +12753,10 @@ export interface ContainerResource { publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): this; /** - * Configures the resource to run as a hosted agent in Microsoft Foundry. If a project resource is not provided, the method will attempt to find an existing Microsoft Foundry project resource in the application model. If none exists, a new project resource (and its parent account resource) will be created automatically. - */ - - withComputeEnvironment(options?: { project?: AzureCognitiveServicesProjectResource; configure?: (obj: HostedAgentConfiguration) => Promise }): this; - /** - * Configures the resource to run as a hosted agent in Microsoft Foundry. If a project resource is not provided, the method will attempt to find an existing Microsoft Foundry project resource in the application model. If none exists, a new project resource (and its parent account resource) will be created automatically. + * Configures the resource to run and publish as a hosted agent in Microsoft Foundry, targeting the specified Foundry project. */ - withComputeEnvironment(project?: AzureCognitiveServicesProjectResource, configure?: (obj: HostedAgentConfiguration) => Promise): this; + asHostedAgent(project: AzureCognitiveServicesProjectResource, options?: HostedAgentOptions): IResourceWithEndpoints; /** * Assigns the specified roles to the given resource, granting it the necessary permissions on the target Microsoft Foundry resource. This replaces the default role assignments for the resource. */ @@ -13417,15 +13387,10 @@ export interface CSharpAppResource { addEFMigrations(name: string, dbContextTypeName?: string): EFMigrationResource; /** - * Configures the resource to run as a hosted agent in Microsoft Foundry. If a project resource is not provided, the method will attempt to find an existing Microsoft Foundry project resource in the application model. If none exists, a new project resource (and its parent account resource) will be created automatically. + * Configures the resource to run and publish as a hosted agent in Microsoft Foundry, targeting the specified Foundry project. */ - withComputeEnvironment(options?: { project?: AzureCognitiveServicesProjectResource; configure?: (obj: HostedAgentConfiguration) => Promise }): this; - /** - * Configures the resource to run as a hosted agent in Microsoft Foundry. If a project resource is not provided, the method will attempt to find an existing Microsoft Foundry project resource in the application model. If none exists, a new project resource (and its parent account resource) will be created automatically. - */ - - withComputeEnvironment(project?: AzureCognitiveServicesProjectResource, configure?: (obj: HostedAgentConfiguration) => Promise): this; + asHostedAgent(project: AzureCognitiveServicesProjectResource, options?: HostedAgentOptions): IResourceWithEndpoints; /** * Assigns the specified roles to the given resource, granting it the necessary permissions on the target Microsoft Foundry resource. This replaces the default role assignments for the resource. */ @@ -14035,15 +14000,10 @@ export interface DotnetToolResource { publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): this; /** - * Configures the resource to run as a hosted agent in Microsoft Foundry. If a project resource is not provided, the method will attempt to find an existing Microsoft Foundry project resource in the application model. If none exists, a new project resource (and its parent account resource) will be created automatically. + * Configures the resource to run and publish as a hosted agent in Microsoft Foundry, targeting the specified Foundry project. */ - withComputeEnvironment(options?: { project?: AzureCognitiveServicesProjectResource; configure?: (obj: HostedAgentConfiguration) => Promise }): this; - /** - * Configures the resource to run as a hosted agent in Microsoft Foundry. If a project resource is not provided, the method will attempt to find an existing Microsoft Foundry project resource in the application model. If none exists, a new project resource (and its parent account resource) will be created automatically. - */ - - withComputeEnvironment(project?: AzureCognitiveServicesProjectResource, configure?: (obj: HostedAgentConfiguration) => Promise): this; + asHostedAgent(project: AzureCognitiveServicesProjectResource, options?: HostedAgentOptions): IResourceWithEndpoints; /** * Assigns the specified roles to the given resource, granting it the necessary permissions on the target Microsoft Foundry resource. This replaces the default role assignments for the resource. */ @@ -14629,15 +14589,10 @@ export interface ExecutableResource { publishAsDockerComposeService(configure: (arg1: DockerComposeServiceResource, arg2: Service) => Promise): this; /** - * Configures the resource to run as a hosted agent in Microsoft Foundry. If a project resource is not provided, the method will attempt to find an existing Microsoft Foundry project resource in the application model. If none exists, a new project resource (and its parent account resource) will be created automatically. - */ - - withComputeEnvironment(options?: { project?: AzureCognitiveServicesProjectResource; configure?: (obj: HostedAgentConfiguration) => Promise }): this; - /** - * Configures the resource to run as a hosted agent in Microsoft Foundry. If a project resource is not provided, the method will attempt to find an existing Microsoft Foundry project resource in the application model. If none exists, a new project resource (and its parent account resource) will be created automatically. + * Configures the resource to run and publish as a hosted agent in Microsoft Foundry, targeting the specified Foundry project. */ - withComputeEnvironment(project?: AzureCognitiveServicesProjectResource, configure?: (obj: HostedAgentConfiguration) => Promise): this; + asHostedAgent(project: AzureCognitiveServicesProjectResource, options?: HostedAgentOptions): IResourceWithEndpoints; /** * Assigns the specified roles to the given resource, granting it the necessary permissions on the target Microsoft Foundry resource. This replaces the default role assignments for the resource. */ @@ -14974,15 +14929,10 @@ export interface FoundryDeploymentResource { // augments handle type FoundryResource with extension methods export interface FoundryResource { /** - * Configures the resource to run as a hosted agent in Microsoft Foundry. If a project resource is not provided, the method will attempt to find an existing Microsoft Foundry project resource in the application model. If none exists, a new project resource (and its parent account resource) will be created automatically. + * Configures the resource to run and publish as a hosted agent in Microsoft Foundry, targeting the specified Foundry project. */ - withComputeEnvironment(options?: { project?: AzureCognitiveServicesProjectResource; configure?: (obj: HostedAgentConfiguration) => Promise }): this; - /** - * Configures the resource to run as a hosted agent in Microsoft Foundry. If a project resource is not provided, the method will attempt to find an existing Microsoft Foundry project resource in the application model. If none exists, a new project resource (and its parent account resource) will be created automatically. - */ - - withComputeEnvironment(project?: AzureCognitiveServicesProjectResource, configure?: (obj: HostedAgentConfiguration) => Promise): this; + asHostedAgent(project: AzureCognitiveServicesProjectResource, options?: HostedAgentOptions): IResourceWithEndpoints; /** * Assigns the specified roles to the given resource, granting it the necessary permissions on the target Microsoft Foundry resource. This replaces the default role assignments for the resource. */ @@ -15298,15 +15248,10 @@ export interface IResourceWithEndpoints { withBrowserLogs(browser?: string, profile?: string, userDataMode?: BrowserUserDataMode): this; /** - * Configures the resource to run as a hosted agent in Microsoft Foundry. If a project resource is not provided, the method will attempt to find an existing Microsoft Foundry project resource in the application model. If none exists, a new project resource (and its parent account resource) will be created automatically. + * Configures the resource to run and publish as a hosted agent in Microsoft Foundry, targeting the specified Foundry project. */ - withComputeEnvironment(options?: { project?: AzureCognitiveServicesProjectResource; configure?: (obj: HostedAgentConfiguration) => Promise }): this; - /** - * Configures the resource to run as a hosted agent in Microsoft Foundry. If a project resource is not provided, the method will attempt to find an existing Microsoft Foundry project resource in the application model. If none exists, a new project resource (and its parent account resource) will be created automatically. - */ - - withComputeEnvironment(project?: AzureCognitiveServicesProjectResource, configure?: (obj: HostedAgentConfiguration) => Promise): this; + asHostedAgent(project: AzureCognitiveServicesProjectResource, options?: HostedAgentOptions): IResourceWithEndpoints; } // augments handle type IResourceWithEnvironment with extension methods @@ -16573,15 +16518,10 @@ export interface ProjectResource { addEFMigrations(name: string, dbContextTypeName?: string): EFMigrationResource; /** - * Configures the resource to run as a hosted agent in Microsoft Foundry. If a project resource is not provided, the method will attempt to find an existing Microsoft Foundry project resource in the application model. If none exists, a new project resource (and its parent account resource) will be created automatically. - */ - - withComputeEnvironment(options?: { project?: AzureCognitiveServicesProjectResource; configure?: (obj: HostedAgentConfiguration) => Promise }): this; - /** - * Configures the resource to run as a hosted agent in Microsoft Foundry. If a project resource is not provided, the method will attempt to find an existing Microsoft Foundry project resource in the application model. If none exists, a new project resource (and its parent account resource) will be created automatically. + * Configures the resource to run and publish as a hosted agent in Microsoft Foundry, targeting the specified Foundry project. */ - withComputeEnvironment(project?: AzureCognitiveServicesProjectResource, configure?: (obj: HostedAgentConfiguration) => Promise): this; + asHostedAgent(project: AzureCognitiveServicesProjectResource, options?: HostedAgentOptions): IResourceWithEndpoints; /** * Assigns the specified roles to the given resource, granting it the necessary permissions on the target Microsoft Foundry resource. This replaces the default role assignments for the resource. */ @@ -16876,6 +16816,7 @@ export interface CookieSecurePolicy {} export interface ForwardedTransformActions {} export interface HeaderMatchMode {} export interface HealthStatus {} +export interface HostedAgentOptions {} export interface HttpVersionPolicy {} export interface IAppIdentityResource {} export interface IAsyncDisposable {}