AuthenticationError 401 - Principal Does Not Have Access to API/Operation when using Azure Open AI with Python SDK

Nuzhi Meyen 0 Reputation points
2024-08-13T01:55:04.29+00:00

Issue Summary:

Encountering an AuthenticationError with error code 401 when attempting to access the OpenAI API. The error message indicates that the principal does not have access to the API/Operation.

Expected Outcome:

The service principal should have access to the specified API/Operation based on the roles and permissions assigned.

Actual Outcome:

Receiving the following error message: Principal does not have access to API/Operation. This prevents the service principal from accessing the API as expected.

Environment Details:

  • Subscription ID: Redacted
  • Role(s) Assigned: Contributor , User
  • Application ID: Redacted
  • API/Operation: Microsoft.CognitiveServices/accounts/listKeys/action
  • Azure Resource: Redacted

Appreciate any support on the above

Thanks,

Best Regards,

Nuzhi

Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
2,878 questions
{count} votes

1 answer

Sort by: Most helpful
  1. navba-MSFT 23,095 Reputation points Microsoft Employee
    2024-08-13T02:03:03.9833333+00:00

    @Nuzhi Meyen Welcome to Microsoft Q&A Forum, Thank you for posting your query here!

    .

    Please assign the RBAC role Cognitive Services Contributor to the user (Service principal) from Azure portal for your Azure Open AI resource. Then test this from your application and check if that helps.

    .

    Awaiting your reply.

    1 person found this answer helpful.
    0 comments No comments

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.