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

2 answers

Sort by: Most helpful
  1. Gowtham CP 6,920 Reputation points Volunteer Moderator
    2025-09-09T08:45:20.62+00:00

    Hello Sambhav Yadav,

    Thank you for reaching out on Microsoft Q&A.

    The error Access denied due to invalid subscription key or wrong API endpoint usually occurs when:

    The subscription key used is invalid or expired.

    The endpoint URL does not match the region where your Computer Vision resource is deployed.

    The resource itself is disabled or deleted.

    Please check the following:

    In the Azure portal, go to your Computer Vision resourceKeys and Endpoint.

    Ensure you are using the correct key and the matching regional endpoint in your code. For example:

    https://<your-resource-name>.cognitiveservices.azure.com/
    

    Replace any hardcoded or incorrect endpoint/keys with the values from your portal.

    For more details, see Microsoft documentation here:
    Authenticate requests to Azure AI services

    I hope this helps.

    If the information is useful, please accept the answer and upvote it to assist other community members.

    0 comments No comments

  2. Pavankumar Purilla 11,405 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.