{"record":{"id":"8ec1655e3646cbc3","repo":"microsoft/aspire","slug":"failed-to-resolve-connection-id-for-bing-grounding-tool-name","errorCode":null,"errorMessage":"Failed to resolve connection ID for Bing Grounding tool '{Name}'. The Foundry project connection may not have been provisioned correctly.","messagePattern":"Failed to resolve connection ID for Bing Grounding tool '(.+?)'\\. The Foundry project connection may not have been provisioned correctly\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Foundry/ToolResources/BingGroundingToolResource.cs","lineNumber":67,"sourceCode":"    /// 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}\n","sourceCodeStart":49,"sourceCodeEnd":77,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Foundry/ToolResources/BingGroundingToolResource.cs#L49-L77","documentation":"Thrown by BingGroundingToolResource.ToAgentToolAsync when the Bicep output 'id' on the Foundry project's Bing connection resource resolves to null or empty. The library needs the provisioned connection's resource ID to build the BingGroundingSearchConfiguration; without it the grounding tool cannot be wired up. This indicates the connection resource did not complete provisioning or produced no id output.","triggerScenarios":"Calling WithAgentTool/ToAgentToolAsync on a BingGroundingToolResource whose underlying Connection Bicep resource has been provisioned but returned an empty 'id' output — e.g. deployment partially failed, the Bing resource name is wrong, or the Foundry project lacks the Bing connection.","commonSituations":"The Bing Grounding connection was deleted or renamed in the Azure portal while the app model still references it; ARM deployed the connection but it returned no id; running locally against a Foundry project where the Bing connection was never provisioned; casing/typo in the connection name passed to the Bing grounding tool builder.","solutions":["Verify the Bing Grounding connection exists in the Foundry project in the Azure portal and is in a succeeded provisioning state.","Re-run the deployment (redeploy the App Host / publish) so the connection Bicep resource re-executes and emits the id output.","Confirm the connection name used when creating BingGroundingToolResource matches the provisioned connection exactly.","Check ARM deployment logs for errors on the connection resource and fix the underlying deployment failure."],"exampleFix":"// before\nvar bing = foundry.AddBingGroundingTool(\"bing\"); // connection name 'bing' not provisioned\n// after\nvar bing = foundry.AddBingGroundingTool(\"my-bing-connection\"); // matches the provisioned connection name in the Foundry project","handlingStrategy":"try-catch","validationCode":"// Before building the agent tool, confirm the connection exists in the Foundry project:\n// var project = await foundryProjectResource.GetAsync(ct);\n// ensure a connection with the expected Bing resource name and Succeeded state exists.","typeGuard":null,"tryCatchPattern":"try\n{\n    await bingTool.ToAgentToolAsync(ct);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Failed to resolve connection ID\"))\n{\n    logger.LogError(ex, \"Bing Grounding connection not provisioned for {Tool}; check the Foundry project connections.\", bingTool.Name);\n    throw;\n}","preventionTips":["Provision the Bing Grounding connection in the Foundry project before running the App Host.","Use the exact provisioned connection name when creating the tool resource.","Check the Azure portal for the connection's provisioning state after deployment failures."],"tags":["azure","foundry","provisioning","connection-id"],"backgroundTag":"resource-not-found","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"}