34

I want to use an API, but I can't find the Ocp-Apim-Subscription-Key at the page below:

enter image description here

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
YJ. Yang
  • 978
  • 2
  • 11
  • 19

9 Answers9

25

You can find it by going to API Management services, then APIs. Select your API, your endpoint and then select the Test tab on the right hand side. Go down to Headers and against Ocp-Apim-Subscription-Key you will see it hidden; select the eye to see it.

enter image description here

RBT
  • 24,161
  • 21
  • 159
  • 240
Patrick Gawley
  • 359
  • 3
  • 5
5

Method 1: From https://portal.azure.com/ go to your API Management service -> Subscriptions There will find default ones and some created by your own.

Method 2: Via https://resources.azure.com/ using HTTP GET method

az rest --method get `
--uri 'https://management.azure.com/subscriptions/{SUBSCRIPTION_ID}/resourceGroups/{RESOURCE_GROUP_NAME}/providers/Microsoft.ApiManagement/service/{API_MANAGER_NAME}/subscriptions?api-version=2018-01-01' `
--query "value[0].properties.primaryKey" | ConvertFrom-Json

Explanation:

  • Replace placeholders {SUBSCRIPTION_ID},{API_MANAGER_NAME},{RESOURCE_GROUP_NAME} by your own values
  • "value[0]. -> indicates the required key value: first,second in the list, because as you can see in the portal there are multiple for different scopes: Starter, Service access, Unlimited etc.
  • properties.primaryKey -> each value has 2 defined keys: primaryKey and secondaryKey
  • api-version=2018-01-01 -> check the right version, can be found from https://resources.azure.com/ or from ARM template for the API Manager resource
jhook
  • 161
  • 2
  • 4
5

Not sure where everyone is getting their answers from...
Maybe it's just old information, but at this time you can find them by doing the following:

  1. Go to portal.azure.com
  2. Select "Create a resource"
  3. Create a resource. I'm using computer vision so I search for that and hit enter
  4. Select "create"
  5. Go to the newly created resource
  6. On the left side panel under the "Resource Management" section select "Keys and Endpoint"

Key 1 and Key 2 are used as the "Ocp-Apim-Subscription-Key".
That's it. Those should work for you wherever it asks for the "Ocp-Apim-Subscription-Key".

סטנלי גרונן
  • 2,917
  • 23
  • 46
  • 68
Josh Lear
  • 99
  • 1
  • 2
5

I found the subscription key here:

  1. In the Azure portal, navigate to the "API Management service".
  2. Go to "Subscriptions" under the "APIs"-heading.
  3. Press "Add subscription".
  4. Enter a "Name", select API as "Scope" then select your API under "API".
  5. Press "Save". This will create a subscription for the selected API.
  6. In the list of subscriptions, locate the subscription you just created, then press the "..."-button to the far right.
  7. Press "Show/hide keys".
  8. The subscription key is visible and can be copied from the "Primary key"-field.
Reyhn
  • 997
  • 1
  • 11
  • 22
4

please, following the instructions below.

  1. You have to go through the azure portal and select your API management component then click on the Publisher Portal in the left top corner.
  2. Go through the APIs and then Products tab.
  3. Click on the ADD API TO PRODUCTS button and then select an appropriate option.
  4. Go through the azure portal again, but click on the Developer Portal in the left top corner.
  5. Click on the ComboBox which is placed on the right side and choose Profile.
  6. You will be able to see the access keys for the products and pick the key for the product which you have chosen in the previous steps (Starter or Unlimited).
Aliaksei Futryn
  • 461
  • 5
  • 8
  • 8
    I am not able to follow these steps. I can find _API Management services_, but from there I am lost. – JonathanPeel May 17 '18 at 19:30
  • 1
    There is no Developer Portal link, in the top left corner. Can you update please? I can't find the developer portal at all. – Joshua Stafford Nov 01 '19 at 01:29
  • 2
    Please update the answer, as on July-19-2021 the option you mentioned doesn't match with the updated UI. @patrick Gawley's answer works as of today! – Here_2_learn Jul 19 '21 at 16:56
3

This is how I found the keys

  • go to the resource
  • Click developer portal
  • Click the username on right-handhand side (for me it was "Administrator"). This will drop down a menu list
  • Click Profile
  • See a list of all keys. you can click the show link to view the keys and copy them
RooN3y
  • 144
  • 1
  • 7
1

(August 2018) For our purposes (AI / ML) I found it under Cognitive Services > Resource Management > Keys - https://portal.azure.com/#blade/HubsExtension/Resources/resourceType/Microsoft.CognitiveServices%2Faccounts

It will be under other services though I can't say which (as you have to be using one to see the attributes of it).

HankCa
  • 9,129
  • 8
  • 62
  • 83
0

It's also called the Programmatic Key. As of January 2018, if you log on to luis.ai, you can find it under settings (when you click on your name in the upper right hand corner).

Not sure why the LUIS Api documentations say the key is in azure and why there's a naming difference :/

Berty
  • 1
  • 2
  • 1
    As of July 2018, it's called "Authoring Key" and it is still under your user settings. It looks like they keep renaming it. – Irina Jul 10 '18 at 14:57
0

A subscription key is associated to a subscription. You can go the specific API's subscription you want the keys to (Home / API Management services / [Your APIM] / Subscriptions / [Your API's subscription]), you'll find the keys clicking in in the ellipsis (three dots) button, option "Show/hide keys":

enter image description here

Gedeon
  • 742
  • 9
  • 13