Forum Discussion

Uzmakhan's avatar
Uzmakhan
Copper Contributor
Sep 08, 2025

Agent in Azure AI Foundry not able to access SharePoint data via C# (but works in Foundry portal)

Hi Team,

I created an agent in Azure AI Foundry and added a knowledge source using the SharePoint tool. When I test the agent inside the Foundry portal, it works correctly; it can read from the SharePoint site and return file names/data.

However, when I call the same agent using C# code, it answers normal questions fine, but whenever I ask about the SharePoint data, I get the error:

Sorry, something went wrong. Run status: failed

I also referred to the official documentation and sample here:
https://learn.microsoft.com/en-us/azure/ai-foundry/agents/how-to/tools/sharepoint-samples?pivots=rest

I tried the cURL samples as well, and while the agent is created successfully, the run status always comes back as failed.

Has anyone faced this issue? Do I need to configure something extra for SharePoint when calling the agent programmatically (like additional permissions or connection binding)?

 

Any help on this would be greatly appreciated.
Thanks!

1 Reply

  • pradejain's avatar
    pradejain
    Iron Contributor

    The most common reason for the “Run status: failed” error is that the SharePoint tool isn’t properly bound to the agent during your programmatic call. Even if the agent was created with the tool, you still need to make sure the connection ID is passed correctly, and that your message actually references the SharePoint resource in a way the agent understands.

    Also, permissions matter. The identity you're using in your C# app (like DefaultAzureCredential) needs to have access to both the Azure AI Foundry project and the SharePoint site. If it doesn’t, the agent can’t reach the data—even though it works in the portal where your identity is already authorized.

Resources