How do I use Azure AI Foundry endpoints and avoid permission errors

Daniel Basher 0 Reputation points
2024-11-27T17:02:12.8066667+00:00

I am new to Azure and I am trying to get the following tutorial working.

I have tried following the tutorial to provision with azd, I have even used a dev container, github codespaces and manually tried to make the required environmental variables.

Whenever I try to run the tests which check for a connection to AI foundry endpoints with ! python -m pytest --rootdir=infra/tests/

I get the permission errors openai.AuthenticationError: Error code: 401 - {'error': {'code': 'PermissionDenied', 'message': 'Principal does not have access to API/Operation.'}} . I did some googling and it said to do an app registration and pass the AZURE_CLIENT_ID into the .env file and then add the Microsoft Cognitive services "user_impersonation" permission. however I tried this and it still did nothing.

To reiterate this happens even using azd and setting up manual infrastructure so I figure either the code is broken/doesn't explain setup well enough (unlikely), there is something wrong with my Azure account or I am missing something.

Please let me know if anyone knows how to fix this or if you need any further information. Cheers.

Full error: error_code.txt

Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
3,361 questions
Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
2,955 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.