microsoft-foundry / microsoft-foundry/foundry-samples
Azure.RequestFailedException: 'The principal `***` lacks the required data action
@meerakurup is already working on this.
Since Jul 7, 2025.
- Dominant language
- Bicep
- Stars
- 445
- Forks
- 494
- Avg merge
- 11h 35m
- Merged PRs (30d)
- 38
Description
I'm trying to use any of C# samples that leverage using PersistentAgentsClient.
I guess, the problem is the configuration, which is not clearly described.
For example, the following code fails:
PersistentAgentsClient client = AzureAIAgent.CreateAgentsClient("https://***-resource.services.ai.azure.com/api/projects/my-agents-samples", new AzureCliCredential());
PersistentAgent definition = await client.Administration.CreateAgentAsync(
"gpt-4o",
name: "SkAgent01",
description: "Sample Agent",
instructions: "Helper");
Getting the following error:
Azure.RequestFailedException: 'The principal
***lacks the required data actionMicrosoft.CognitiveServices/accounts/AIServices/agents/writeto performPOST /api/projects/{projectName}/assistantsoperation. For instructions on granting the necessary permissions, see https://aka.ms/FoundryPermissions.
Status: 401 (PermissionDenied)
Btw. I have created the project. I'm logged in CLI for sure.
My user is added twice in the user's list: Cognitive Services User and Cognitive Services Contributor.
I have tried using AzureCliCredential and DefaultAzureCredential. Is there some way to use the ApiKey?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.