A unified Azure platform for creating and managing AI models, agents, and applications with built‑in enterprise security, monitoring, and governance
Hello Souciance Eqdam Rashti,
Greetings! Thanks for raising this question in the Q&A forum.
The ServerError[500] coming back from the toolbox's file_search tool call is a backend error on the file search execution path, not a problem with your C# hosting code itself. The vector store showing status "completed" only confirms that ingestion finished, it does not confirm that the runtime identity used by your hosted container can actually query that vector store and its underlying storage. Since the hosted C# integration relies on AddFoundryToolboxes(credential, ...) to call the toolbox MCP endpoint directly with DefaultAzureCredential, a 500 at query time most commonly comes from one of the following:
Missing role assignment on the identity used inside the hosted container. The identity that created the vector store (typically your own signed-in az login identity when testing locally, or a different identity if this was done through the Foundry portal) is not necessarily the same identity your hosted agent uses at runtime. Confirm the identity resolved by DefaultAzureCredential in your hosted container has both of these roles on the project:
- Storage Blob Data Contributor on the project's storage account
- Foundry User on the Foundry project (previously named Azure AI User)
file_searchtool are a newer capability. Confirm your Foundry project's region is listed as supporting this combination:
https://learn.microsoft.com/en-us/azure/foundry/reference/region-support
- Isolate whether the issue is toolbox-specific or vector-store-specific. Call the vector store directly through the REST API using the same bearer token flow, bypassing the toolbox and hosted agent entirely:
curl --request GET \
--url $FOUNDRY_PROJECT_ENDPOINT/openai/v1/vector_stores/vs_aSG7XqAQOxrEUiq6OCW7qDZq \
-H "Authorization: Bearer $AGENT_TOKEN"
If this also intermittently fails or returns errors, the problem sits with the vector store or its underlying search resource rather than with the hosted agent or toolbox wiring.
- Confirm the toolbox connection setup matches the documented pattern. For hosted C# agents,
AddFoundryToolboxesauthenticates the toolbox MCP call directly with the credential you pass in, it does not go through a "remote-tool" project connection the way the REST and TypeScript flows do. Double check you are following the maintained sample rather than mixing the REST-based connection pattern with the hosted C# pattern:
https://github.com/microsoft/agent-framework/tree/main/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox
If the RBAC and region checks come back clean and the direct REST call to the vector store also fails or returns 500 intermittently, this points to a platform-side issue on the file search backend that cannot be diagnosed further from outside. In that case, open a Technical support request under Microsoft Foundry > Agent Service, and include:
- Request ID:
77b55650-a284-4285-9c45-02755372c66c - Vector store ID:
vs_aSG7XqAQOxrEUiq6OCW7qDZq - Toolbox name:
index_epic_whistle_ht0mz00ttd
If this answer helps you kindly accept the answer which will help others who have similar questions.
Best Regards,
Jerald Felix.