Microsoft Cognitive Services - Computer Vision: Invalid Subscription Key - azure

I'm trying to use the Computer Vision API from Microsoft's Cognitive Services. However, my keys don't seem to be working. I created an account using the free trial of that API and got the two keys from it. Trying to use the key with the ProjectOxford.Vision SDK always yields:
Access denied due to invalid subscription key. Make sure to provide a valid key for an active subscription.
I tried the API console, however I get the same error with my key in the Ocp-Apim-Subscription-Key field. I tried both keys and neither of them work. I even got the free version of Face API and tried its console, but encountered the same issue with its keys. I even tried different datacenters, but they all seem to return the same error.
This would need to be some problem with the key then right? This can't be a problem with my C# code, since the console doesn't work either. And since it's failing in the API console, there's nothing more I can do to rule out any other possibilities is there? I'm not sure what else I can do to debug this. I'd like to regenerate my keys (I saw a tutorial video which showed an older UI of getting the API keys and they used to have a "regenerate" link) but I don't see a way of doing that anymore.
I only just made the account and registered for the APIs, so there's no way I'd be over quota. Is there something else I need to do to enable these keys or something?

I managed to skirt around the issue of 'Access Denied' by performing the following actions:
I created a free Azure account
I set up an instance of the Cognitive Services Api (this generated a pair of new keys for me to use)
Utilizing the new key, I had to use the following link:
https://westus.api.cognitive.microsoft.com/vision/v1.0/ocr
Instead of
https://westus.api.cognitive.microsoft.com/vision/v1.0/recognizeText
(I obtained this link from the Cognitive Services Test Dashboard).
Look at the request pattern on the test dashboard and you should be able to tell how to use the api.

Even when #Xuan Hu response states correctly to the solution, I scratched my head some time trying to figure out how to change the end point. Here are my 2 cents:
Go to portal.azure.com, in the dashboard of your subscription to the Cognitive Services > General Information > End Point take note of the URL. You need it.
Find in the code of your VisionAPI samples where the VisionServiceClient is instantiated:
VisionServiceClient VisionServiceCliente = new VisionServiceClient(SubscriptionKey);
and change including the URL that you found in Azure:
VisionServiceClient VisionServiceCliente = new VisionServiceClient(SubscriptionKey, StringOfMyURLTakedFromPortal);
That worked for me.

If you are using the free trial keys got from azure.microsoft.com. You need to change the API endpoint region to westcentralus. The previous default region is westus and I think that is the reason of the invalid key problem.

FYI, there is a blog post that covers all of the 401 Access Denied scenarios, including this one regarding the free API keys and region specific API endpoint. Adding it here for folks in the future who find this SO post - https://blogs.msdn.microsoft.com/kwill/2017/05/17/http-401-access-denied-when-calling-azure-cognitive-services-apis/.
Using the incorrect regional endpoint
Most of the Cognitive Services APIs are region specific, which means that during API account creation you select which region you want to create the account in. These APIs have region specific endpoints such as westus.api.cognitive.microsoft.com or eastus2.api.cognitive.microsoft.com, and an API key for an account created in one region will only work using the endpoint for that specific region. This means that if you create an API account in West US you will not be able to call the eastus2.api.cognitive.microsoft.com API endpoint.
You can verify the region and endpoint in the Azure management portal.
Trial API Keys
The free trial API keys have 30 day expiration dates, and the same restrictions for region and version. If you are using the trial keys you can go to https://azure.microsoft.com/en-us/try/cognitive-services/my-apis/ to manage your API keys (if you are not already logged in then just click one of the ‘Create’ buttons and you can go through the wizard to login and see your existing API keys), and you will also see the expiration date and endpoint.

One thing to remember if using Postman to get the results is to use GET and put your keys in the Header.

Related

In Azure Cognitive Services Text Translation what is the endpoint `https://<resource name>.cognitiveservices.azure.com/sts/v1.0/issuetoken` for?

Want to try out the Text Translation API from , I created my text translation resource, as described at https://www.microsoft.com/en-us/translator/business/trial/#get-started, and was presented with a subscription key and an endpoint https://<resource name>.cognitiveservices.azure.com/sts/v1.0/issuetoken.
I proceeded to replicate the sample code from https://learn.microsoft.com/en-us/azure/cognitive-services/translator/quickstart-translate?pivots=programming-language-csharp (also on Github).
That code wants the subscription key and endpoint added as environment variables, and I did so, using the strings provided to me when creating the resource. However, trying to run the sample code it fails with a 404 when going to the endpoint. Looking more carefully at https://learn.microsoft.com/en-us/azure/cognitive-services/translator/quickstart-translate?pivots=programming-language-csharp, I noticed that it told me to use https://api.cognitive.microsofttranslator.com/ as endpoint, not the URL above. After that change, the code worked.
So what is the https://<resource name>.cognitiveservices.azure.com/sts/v1.0/issuetoken endpoint for? Certainly one gets the impression it's the endpoint to use for translation requests, so maybe clarify the documentation there?

API for registering your app to Azure

I am trying to write an app that, upon receiving the credentials of an Azure user, will be able to show him various pieces of information using the Azure billing apis.
However, the following git sample that shows how to use one of those apis, lists a series of steps that should be done in the Azure cloud platform in order for things to work, and these steps need to be done by the user himself. Specifically, step 1 talks about registering an app and configuring it so that it has access and permissions to use the apis.
Only after those steps, will I be able to access the billing apis and retrieve his information.
Seeing as how I don't want the user to have to do anything after he gives me his username and password, is there an API or some other automated way with which I can register my app to view his account?
https://github.com/Azure-Samples/billing-dotnet-usage-api
Ideally, I would want some sort of imaginary code that maybe looks like:
someObj obj = someAPI.loginToAzureWithCredentials("123456", "someUserName")
obj.registerApplication();
Obviously the "code" is very lacking in details, but it's just for emphasizing what I'm searching for.

From free to paid subscription on LUIS

I recently reached the limit for the free LUIS usage. I first created the LUIS app directly on the LUIS.ia portal and used those keys on my code. Now I wanted to get the paid option to continue using it so I created an azure resource for LUIS.ia I then went to the LUIS.ia app and added the azure resource throught the Publish>>Add Key on the LUIS.ia portal. I then changed on my code the subscriptionKey for one of the two from the new keys but it is still not working. What did I do wrong?
One answer that probably isn't applicable at this time is that it will take time for an Azure resource to successfully propogate throughout Azure. What this means in the case of newly created LUIS Subscription keys, is that it can take up to ten minutes for a newly created LUIS Subscription Key in Azure to be valid to LUIS.
However, the steps you outlined indicate that you might be missing this next part.
After you created the key in Azure, you should have associated the key with the LUIS application you wish to use it with. Following a successful LUIS Subscription Key association in the LUIS Portal with one of your applications, the next step is to continue to your bot's code and change the previous key, to your new key.
Depending on which the error codes you're getting when you try to use LUIS will help with unblocking you.
If you're getting a 401, that means the key you're using is invalid, which might mean either the wrong region, or that the key hasn't finished propagating.
If it's a 403, that usually means you're out of your monthly quota, which would imply that the key being used in your LUIS queries are of the free-tier or is the Authoring/Programmatic API Key, so the key needs to be replaced with your paid-tier LUIS Subscription Key.
Edit for BotBuilder .NET v3 users:
For users of the .NET v3 SDK, when instantiating the LuisModel, if you are using a region other than westus, you must pass in the correct domain. An example of this in action can be found here, but I've also included the code below:
[LuisModel("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX",
"XXXXXXXXXXXXXXXXX", domain: "eastus2.api.cognitive.microsoft.com")]

401 Errors Calling the Microsoft Luis.ai Programmatic API

ASKING THIS HERE AT THE EXPLICIT REQUEST OF THE MICROSOFT AZURE SUPPORT TEAM.
I've been attempting to call the MS Luis.ai programmatic API (bit.ly/2iev01n) and have been receiving a 401 unauthorized response to every request. Here's a simple GET example: https://api.projectoxford.ai/luis/v1.0/prog/apps/{appId}/entities?subscription-key={subscription_key}.
I am providing my appId from the Luis.ai GUI (as specified by the API docs), here:
I am providing my subscription key from Azure (as specified by the API docs), here:
The app ID and subscription key, sourced from above, are the exact same as what I'm using to hit the query API successfully (see note at bottom). My account is pay-as-you-go (not free).
Am I doing something wrong here? Is this API deprecated, moved, down, or out-of-sync with the docs?
NOTE: I can manipulate my model through the online GUI but that approach will be far too manual for our business needs where our model will need to be programmatically updated as new business entities come into existence.
NOTE: The programmatic API is different from the query API which has this request URL, which is working fine for me:
https://api.projectoxford.ai/luis/v2.0/apps/{appId}?subscription-key={subscription_key}&verbose=true&q={utterance}
NOTE: There doesn't seem to be a Luis.ai programmatic API for v2.0--which is why the URLs from the query and programmatic APIs have different versions.
Answering my own question here:
I have found my LUIS.ai programmatic API key. It is found by:
LUIS.ai dashboard -> username (upper-right) -> settings in dropdown -> Subscription Keys tab -> Programmatic API Key
It was not immediately obvious since it's found nowhere else: not alongside any of the other key listings in cognitive services or the LUIS.
the programatic key for Luis is here ,
https://www.luis.ai/Home/UserSettings

SOAP API- This Account lacks sufficient permissions

I am getting below error while accessing DocuSign SOAP service using SOAP UI tool. I also tried using integration key in username [Integration Key]userguid format I got same exception.
Can you please help me to resolve this issue.
Ok I've found out which option it is, and have enabled this option on your account. You should be able to export authoritative copies from this account now. For reference sake, the option I enabled was a member setting called
Can Export Authoritative Copies?
Please note, though, that since this is a setting that we have to enable on DocuSign's side, that means that it might be an enterprise or workgroup level feature. On your demo account we enable whatever you like so you can test things out, however when you are ready to move to production and purchase a corresponding production account that uses the API, you'll need to make sure you purchase an account that allows this feature. You can find out more from your Account Manager.

Resources