Skip to content

Group AddAzureFunctionTool parameters into an options type - #22253

Merged
Adam Ratzman (adamint) merged 2 commits into
mainfrom
tommasodotnet-azure-function-tool-options
Nov 25, 2026
Merged

Adam Ratzman (adamint) merged 2 commits into
mainfrom
tommasodotnet-azure-function-tool-options

Conversation

@tommasodotNET

Copy link
Copy Markdown
Contributor

Description

AddAzureFunctionTool currently takes a long list of positional arguments, including input and output queue endpoint/name pairs. Grouping the configuration makes call sites easier to read and allows configuration to evolve without adding more overloads.

Replace both preview overloads with AddAzureFunctionTool(name, AzureFunctionToolOptions). The required options capture the function definition and queue bindings. ParametersJson keeps the same options type usable from C# and TypeScript. Existing resource construction, argument validation, and serialized agent-tool output are preserved.

Fixes: #16610

User-facing usage

C# AppHost:

var functionTool = project.AddAzureFunctionTool("weather-tool", new AzureFunctionToolOptions
{
    FunctionName = "get_weather",
    Description = "Gets the weather for a city.",
    ParametersJson = """{"type":"object","properties":{"city":{"type":"string"}}}""",
    InputQueueEndpoint = "https://storage.queue.core.windows.net",
    InputQueueName = "weather-input",
    OutputQueueEndpoint = "https://storage.queue.core.windows.net",
    OutputQueueName = "weather-output"
});

TypeScript AppHost:

const functionTool = await project.addAzureFunctionTool("weather-tool", {
    functionName: "get_weather",
    description: "Gets the weather for a city.",
    parametersJson: JSON.stringify({ type: "object", properties: { city: { type: "string" } } }),
    inputQueueEndpoint: "https://storage.queue.core.windows.net",
    inputQueueName: "weather-input",
    outputQueueEndpoint: "https://storage.queue.core.windows.net",
    outputQueueName: "weather-output"
});

Breaking changes

Callers of the preview positional overloads must move configuration into AzureFunctionToolOptions. C# callers using BinaryData must supply its JSON text through ParametersJson. The resource constructor remains unchanged; generated API compatibility baselines are not edited.

Validation

Added focused coverage for options-to-resource mapping, null options, null schema, and null/empty queue names. The existing serialized agent definition snapshot is unchanged.

Passed, 43 tests:

DOTNET_USE_POLLING_FILE_WATCHER=1 MSBUILDTERMINALLOGGER=false dotnet test --project tests/Aspire.Hosting.Foundry.Tests/Aspire.Hosting.Foundry.Tests.csproj --no-launch-profile -p:PublicSign=true -- --filter-class '*.PromptAgentTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'

The process-local settings accommodate the host's exhausted inotify quota and OpenSSL strong-name signing restriction. The test project also rebuilt successfully with zero warnings and errors. Generated the TypeScript SDK from the updated Foundry assembly and inspected the options DTO, method signature, and documentation. No live Azure deployment was run; runtime/deployment behavior is unchanged.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

@tommasodotNET Tommaso Stocchi (tommasodotNET) added the breaking-change Issue or PR that represents a breaking API or functional change over a prerelease. label Nov 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 22253

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 22253"

@github-actions

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

All four polyglot AppHosts still call the removed eight-argument API and must migrate to the generated options DTO to avoid compilation or type-checking failures after SDK regeneration.

1 open issue
What changed in this PR

This PR addresses #16610 by grouping Foundry Azure Function tool configuration into AzureFunctionToolOptions, simplifying C# and polyglot AppHost calls while preserving resource construction and serialized output.

Changes:

  • Replaces both preview positional overloads with AddAzureFunctionTool(name, options).
  • Documents the options-based API with C# and TypeScript examples.
  • Expands tests for resource mapping and invalid options.
File Description
tests/​Aspire.Hosting.Foundry.Tests/​PromptAgentTests.cs Migrates calls and adds mapping and validation assertions.
src/​Aspire.Hosting.Foundry/​ToolResources/​AzureFunctionToolOptions.cs Adds required function-definition and queue-binding options.
src/​Aspire.Hosting.Foundry/​README.md Documents options-based usage in C# and TypeScript.
src/​Aspire.Hosting.Foundry/​PromptAgent/​PromptAgentBuilderExtensions.cs Replaces positional overloads with the exported options-based method.

Review effort: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Tests selector

3 / 101 PR test projects · 2 PR jobs, from 7 changed files.

Selected PR test projects (3 / 101)

Aspire.Hosting.Azure.Kubernetes.Tests, Aspire.Hosting.Azure.Tests, Aspire.Hosting.Foundry.Tests

Selected PR jobs (2)

polyglot, typescript-api-compat


How these were chosen — grouped by what changed

🔧 src/Aspire.Hosting.Foundry/PromptAgent/PromptAgentBuilderExtensions.cs (changed source)
→ 1 directly: Aspire.Hosting.Foundry.Tests
→ 2 via the project graph: Aspire.Hosting.Azure.Kubernetes.Tests (2 hops), Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Foundry/ToolResources/AzureFunctionToolOptions.cs (changed source)
→ 1 directly: Aspire.Hosting.Foundry.Tests

🧪 tests/Aspire.Hosting.Foundry.Tests/PromptAgentTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Foundry.Tests

Job reasons

Job Triggered by
polyglot • tests/PolyglotAppHosts/Aspire.Hosting.Foundry/Go/apphost.go, tests/PolyglotAppHosts/Aspire.Hosting.Foundry/Java/AppHost.java, tests/PolyglotAppHosts/Aspire.Hosting.Foundry/Python/apphost.py, tests/PolyglotAppHosts/Aspire.Hosting.Foundry/TypeScript/apphost.mts
• affected project Aspire.Hosting.Foundry
typescript-api-compat affected project Aspire.Hosting.Foundry

Selection computed for commit bc3a3ac.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues were identified for the options-based Azure Function tool API refactor.

1 open issue

Review effort: Balanced

@adamint
Adam Ratzman (adamint) merged commit 9fccfb1 into main Nov 25, 2026
61 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 17.1 milestone Nov 25, 2026
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Pull request created: #2252

Generated by PR Documentation Check · copilot · auto (Claude Sonnet 5.5) · ~32 AIC · ⌖ ~10 AIC · ⊞ 7.6K

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

📝 Documentation has been drafted in microsoft/aspire.dev#2252 targeting release/17.1.

Added a breaking-change entry to whats-new/aspire-17.mdx for AddAzureFunctionTool(name, AzureFunctionToolOptions). Signals: new_public_type (AzureFunctionToolOptions.cs), integration_readme_changed (Foundry README), pr_body_has_user_facing_section, pr_label_breaking_change, pr_body_has_cli_flag_mention.

Note

This draft PR needs human review before merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-integrations Issues pertaining to Aspire Integrations packages breaking-change Issue or PR that represents a breaking API or functional change over a prerelease.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Group AddAzureFunctionTool parameters into an options type

3 participants