How to fix "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." issue while getting response

Neha Parate 15 Reputation points
2023-09-29T05:49:42.9733333+00:00

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.

Azure AI Bot Service
Azure AI Bot Service
An Azure service that provides an integrated environment for bot development.
842 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Ramr-msft 17,741 Reputation points
    2023-09-29T07:36:59.0333333+00:00

    Neha Parate Thanks for the question, Can you please add more details about the API call that you are making.

    Make sure to provide a valid key for an active subscription and use a correct regional API endpoint for your resource.” typically occurs when the subscription key or the API endpoint provided is incorrect.

    Here are some steps you can take to resolve this issue:

    Check your subscription key: Make sure that the subscription key you’re using is valid and active. You can usually find this in your Azure portal or the platform where you obtained the API.

    Check your API endpoint: Ensure that you’re using the correct API endpoint for your resource. The endpoint usually depends on the region where your resource is located.

    1. Check your code: If you’re using code to access the API, make sure that the subscription key and the API endpoint are correctly implemented in your code

  2. Vishal Bondwal 0 Reputation points
    2024-08-01T03:42:18.5966667+00:00

    My team was getting the same error in Azure AI. Turns out that some services are automatically created in another region if they are not available in your region. Our entire Azure workloads are in Australia, but when we created the document intelligence service, it silently got created in East US.

    So when you see the Endpoints & Keys section of your dashboard, it will show where you created it (e.g. Australia), but the actual AI service is running elsewhere (e.g. East US). This causes a key/region mismatch. The only place where we could see this contrasting location was in Cost Management > Cost Analysis > Resources.

    We created a new resource in East US, and used the keys and endpoint from there, and it started working without any problem.

    It could possibly be because AI services are not rolled out worldwide, so there is a higher probability of them ending up in a different region than where the keys and endpoint are defined. Also make sure that the key for the API Key is named Ocp-Apim-Subscription-Key, and not apiKey or api-key.

    0 comments No comments

  3. Jason Owens 0 Reputation points
    2024-08-15T00:01:16.0133333+00:00

    Make sure to use the correct endpoint. I was using vision.cognitiveservices.azure.com/ instead of face.cognitiveservices.azure.com/

    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.