Where to find my Ocp-Apim-Subscription-Key in Windows azure

后端 未结 8 1722
时光说笑
时光说笑 2021-01-01 16:32

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

Thanks.

8条回答
  •  被撕碎了的回忆
    2021-01-01 17:19

    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

提交回复
热议问题