{"record":{"id":"3cb939b3fe12713b","repo":"microsoft/aspire","slug":"bing-grounding-tool-name-does-not-have-a-project-connection","errorCode":null,"errorMessage":"Bing Grounding tool '{Name}' does not have a project connection. Ensure the tool was added using AddBingGroundingTool().","messagePattern":"Bing Grounding tool '(.+?)' does not have a project connection\\. Ensure the tool was added using AddBingGroundingTool\\(\\)\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Foundry/ToolResources/BingGroundingToolResource.cs","lineNumber":58,"sourceCode":"    /// <param name=\"project\">The parent Foundry project resource.</param>\n    public BingGroundingToolResource(\n        [ResourceName] string name,\n        AzureCognitiveServicesProjectResource project)\n        : base(name, project)\n    {\n    }\n\n    /// <summary>\n    /// Gets or sets the Bing grounding connection resource for the Bing Search service.\n    /// </summary>\n    internal BingGroundingConnectionResource? Connection { get; set; }\n\n    /// <inheritdoc/>\n    public override async Task<ResponseTool> ToAgentToolAsync(CancellationToken cancellationToken = default)\n    {\n        if (Connection is null)\n        {\n            throw new InvalidOperationException(\n                $\"Bing Grounding tool '{Name}' does not have a project connection. \" +\n                \"Ensure the tool was added using AddBingGroundingTool().\");\n        }\n\n        var connectionIdRef = new BicepOutputReference(\"id\", Connection);\n        var connectionId = await connectionIdRef.GetValueAsync(cancellationToken).ConfigureAwait(false);\n        if (string.IsNullOrEmpty(connectionId))\n        {\n            throw new InvalidOperationException(\n                $\"Failed to resolve connection ID for Bing Grounding tool '{Name}'. \" +\n                \"The Foundry project connection may not have been provisioned correctly.\");\n        }\n\n        var config = new BingGroundingSearchConfiguration(connectionId);\n        var options = new BingGroundingSearchToolOptions([config]);\n        return new BingGroundingTool(options);\n    }\n}","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Foundry/ToolResources/BingGroundingToolResource.cs#L40-L76","documentation":"A Bing Grounding tool must carry a project connection assigned by AddBingGroundingTool (and its WithReference). ToAgentToolAsync throws when Connection is null, meaning the tool was constructed without going through the supported AddBingGroundingTool path or was never wired to a connection.","triggerScenarios":"Creating a BingGroundingToolResource directly or adding it without a connection, then deploying an agent that includes it.","commonSituations":"Manually instantiating the tool resource instead of using the builder API; calling WithReference never ran due to conditionals; refactors that bypass AddBingGroundingTool.","solutions":["Use AddBingGroundingTool() on the Foundry project builder to create the tool, then call WithReference with a Bing connection, string, or parameter resource.","Verify tool.Resource.Connection is non-null before deployment.","Replace any manual construction of BingGroundingToolResource with the builder API."],"exampleFix":"// before\nvar bingTool = new BingGroundingToolResource(\"bing\");\n// after\nvar bingTool = project.AddBingGroundingTool(\"bing\")\n    .WithReference(bingConnection);","handlingStrategy":"validation","validationCode":"if (bingToolBuilder.Resource.Connection is null) throw new InvalidOperationException(\"Add the tool via AddBingGroundingTool() and call WithReference.\");","typeGuard":"bool isLinked(BingGroundingToolResource t) => t.Connection is not null;","tryCatchPattern":null,"preventionTips":["Create Bing tools only through AddBingGroundingTool().","Always pair tool creation with a WithReference call.","Assert Connection non-null before adding tools to agents."],"tags":["azure","foundry","bing","missing-configuration","tool"],"backgroundTag":"missing-required-config","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}