'How to get subscriber ID of an API in Azure APIM?
I am new to Azure APIM and want to know how to get subscriber ID or anything which can uniquely identifies every subscriber of my API.
Solution 1:[1]
You can use APIM management api to get the subscription ID. In your APIM Instance>Management API There you can find the management url and the token to call the endpoint can be generated.
Specifically to get all subscriptions, you can use below endpoint within management url :
GET: https://{your management url}/subscriptions/?api-version=2018-01-01
Or
specifically for a product
https://{your management url}/products/{productId}/subscriptions?api-version=2018-01-01
Below is the Rest API reference https://docs.microsoft.com/en-us/rest/api/apimanagement/subscription
Or within a APIM policy,
you can find using context
variables.
https://docs.microsoft.com/en-us/azure/api-management/api-management-policy-expressions
context.Subscription.Id
Solution 2:[2]
Fo those who are not clear on the answer provided by @VinuBibin, you can get the subscription id during request, inside the policy and inject it into headers as follows:
<set-header name="subscription" exists-action="override">
<value>@(context.Subscription.Id)</value>
</set-header>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | VinuBibin |
Solution 2 | LastTribunal |