microsoft/aspire · error · ArgumentException
Unsupported Bing reference type
Error message
Unsupported Bing reference type '{bingReference.GetType().Name}'. Expected IResourceBuilder<BingGroundingConnectionResource>, string, or IResourceBuilder<ParameterResource>. What it means
The Bing Grounding WithReference overload accepts only an IResourceBuilder<BingGroundingConnectionResource>, a string (connection name), or an IResourceBuilder<ParameterResource>. Any other object falls into the switch's default case and raises this ArgumentException naming the actual runtime type received.
Solutions
- Pass one of the accepted types: a Bing connection resource builder, a string connection name, or a parameter resource builder.
- If you have a connection string, wrap it in a parameter resource: builder.AddParameter("bing-key") and pass that builder.
- Check the PromptAgentBuilderExtensions API docs for the exact accepted overloads.
Example fix
// before
bingTool.WithReference("https://my-bing-endpoint");
// after
var bingParam = builder.AddParameter("bing-connection");
bingTool.WithReference(bingParam); Defensive patterns
Strategy: type-guard
Validate before calling
if (bingRef is not IResourceBuilder<BingGroundingConnectionResource> && bingRef is not string && bingRef is not IResourceBuilder<ParameterResource>) throw new ArgumentException(nameof(bingRef));
Type guard
static bool IsValidBingReference(object bingRef) =>
bingRef is IResourceBuilder<BingGroundingConnectionResource>
|| bingRef is string
|| bingRef is IResourceBuilder<ParameterResource>; Try / catch
try
{
bingTool.WithReference(bingRef);
}
catch (ArgumentException ex)
{
logger.LogError(ex, "Unsupported Bing reference type {Type}", bingRef.GetType().Name);
throw;
} Prevention
- Pass a Bing connection resource builder, string, or parameter resource builder — nothing else.
- Wrap raw connection strings in AddParameter before referencing.
- Check the WithReference overload signature in PromptAgentBuilderExtensions when unsure.
When it happens
Trigger: Passing an unsupported argument type to WithReference on a Bing tool — e.g. IResourceBuilder<ParameterResource> confusion with a raw ParameterResource, a connection string value, or an unrelated resource builder.
Common situations: Misreading the overload's contract and passing a connection string literal or a different resource type; refactors that change argument types without updating call sites.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Bing Grounding tool ' ' does not have a project connection…
- Bing Grounding tool ' ' already has a connection configured.
- Azure AI Search tool
- Azure AI Search tool
- Tool ' ' belongs to project ' ' but agent ' ' belongs to…
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/930a04a72e3a28f3.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting.Foundry/PromptAgent/PromptAgentBuilderExtensions.cs:473
case IResourceBuilder<BingGroundingConnectionResource> connectionBuilder:
tool.Resource.Connection = connectionBuilder.Resource;
break;
case string bingResourceId:
ArgumentException.ThrowIfNullOrEmpty(bingResourceId);
var projectBuilder = tool.ApplicationBuilder.CreateResourceBuilder(tool.Resource.Project);
var connection = projectBuilder.AddBingGroundingConnection($"{tool.Resource.Name}-conn", bingResourceId);
tool.Resource.Connection = connection.Resource;
break;
case IResourceBuilder<ParameterResource> parameterBuilder:
var paramProjectBuilder = tool.ApplicationBuilder.CreateResourceBuilder(tool.Resource.Project);
var paramConnection = paramProjectBuilder.AddBingGroundingConnection($"{tool.Resource.Name}-conn", parameterBuilder);
tool.Resource.Connection = paramConnection.Resource;
break;
default:
throw new ArgumentException(
$"Unsupported Bing reference type '{bingReference.GetType().Name}'. " +
"Expected IResourceBuilder<BingGroundingConnectionResource>, string, or IResourceBuilder<ParameterResource>.",
nameof(bingReference));
}
return tool;
}
// ──────────────────────────────────────────────────────────────
// Configuration-only tools
// ──────────────────────────────────────────────────────────────
/// <summary>
/// Adds a SharePoint grounding tool to a Microsoft Foundry project, enabling agents to
/// search data from SharePoint sites configured as Foundry project connections.
/// </summary>
/// <param name="project">The <see cref="IResourceBuilder{T}"/> for the Microsoft Foundry project.</param>
/// <ats-param name="project">The Microsoft Foundry project resource builder.</ats-param>View on GitHub (pinned to 25830f84bd)