ComputerVision API is gving error while try to connect for getting text from Image

Sambhav Yadav 0 Reputation points
2025-09-09T07:57:33.3566667+00:00

Azure.RequestFailedException: 'Access denied due to invalid subscription key or wrong API endpoint. Make sure to provide a valid key for an active subscription and use a correct regional API endpoint for your resource.

Status: 401 (PermissionDenied)

ErrorCode: 401

Computer Vision
Computer Vision
An Azure artificial intelligence service that analyzes content in images and video.
{count} votes

1 answer

Sort by: Most helpful
  1. Pavankumar Purilla 11,395 Reputation points Microsoft External Staff Moderator
    2025-09-09T09:49:53.9466667+00:00

    Hi Sambhav Yadav,
    The error you are encountering indicates that the Computer Vision API request is failing due to authentication issues. A 401 (PermissionDenied) response usually means that either the subscription key being used is invalid, expired, or not associated with an active Computer Vision resource, or that the request is being sent to the wrong regional endpoint. Each Azure Cognitive Services resource is created in a specific region, and you must use both the correct endpoint URL for that region and the corresponding key from the Azure portal.

    To resolve this, please ensure that you are copying the subscription key from the Keys and Endpoint section of your Computer Vision resource in the Azure portal and that you are using the exact regional endpoint listed there (for example, https://<your-resource-name>.cognitiveservices.azure.com/). If you are still using the global endpoint (https://<region>.api.cognitive.microsoft.com/), we recommend switching to the custom endpoint provided in your resource. Additionally, confirm that your Computer Vision resource is active and not disabled or deleted.

    If after verifying the key and endpoint you still face issues, regenerating a new key from the portal and updating your application with it can help rule out key-related problems. This should allow your requests to authenticate successfully and return the expected text extraction results from images.
    For more information: Authenticate requests to Azure AI services

    0 comments No comments

Your answer

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