Getting 401 when invoking POST /openai/deployments/... API

Syed Razvi 0 Reputation points
2025-08-10T12:39:10.3866667+00:00

I am working on a POC for a chatbot using the instructions provided here. I am trying to execute SQL Script # 4 here and getting the following error:

{"response":{"status":{"http":{"code":401,"description":""}},"headers":{"Date":"Sun, 10 Aug 2025 12:23:47 GMT","Content-Length":"285","Content-Type":"application/json","x-ms-client-request-id":"Not-Set","apim-request-id":"851452ef-b98e-4861-8ecd-fca65bd162a0","strict-transport-security":"max-age=31536000; includeSubDomains; preload","x-content-type-options":"nosniff"}},"result":{"error":{"code":"PermissionDenied","message":"The principal 1d701f4d-ec50-****-95ee-5cb8698533a1 lacks the required data action Microsoft.CognitiveServices/accounts/OpenAI/deployments/embeddings/action to perform POST /openai/deployments/{deployment-id}/embeddings operation."}}}.

I have enabled all possible permissions but have no idea why it's still occurring.

Thanks for any assistance.

Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Amira Bedhiafi 35,766 Reputation points Volunteer Moderator
    2025-08-11T09:41:44.6+00:00

    Hello Syed !

    Thank you for posting on Microsoft Learn.

    Have you verified if the principal has the necessary permissions assigned ?

    From the error message, the permission required is Microsoft.CognitiveServices/accounts/OpenAI/deployments/embeddings/action which should be granted either through a role assigned to the service principal or through custom RBAC.

    The principal must have the appropriate Azure role for accessing OpenAI resources :

    • Cognitive Services OpenAI User
    • Cognitive Services Contributor
    • Or a custom role that grants permission for OpenAI-related actions

    Also, the service principal has access to the specific OpenAI deployment. If the principal does not have access to the deployment, the action will be blocked.

    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.