I have an Azure Function that I’m managing via Azure APIM. I have created a subsciption key for it, however it’s not being enforced. I’ve tested accessing it without the subscription key and it can still get a response. Any idea on how I can restrict it so that you have to pass the subscription key in order to get a response?
Here is proof of my active subscription key
And here if proof that I have Subscription Required enabled
2
Answers
If the request is not made with the incorrect or missing the subscription key,
on-error
section should be executed from thepolicies
.Example code for on-error in XML:
As per the Microsoft Documentation, Predefined errors for built-in steps.
Check it for either of the below options on
authorization
.Thanks
@Vitaliy Kurokhtin
, see this page for additional information.Able to get the message that subscription key is required for getting the response when testing the Function API that has added in the APIM Instance:
If we miss the subscription key passing in headers, it enforces to pass the subscription key for getting response:
If a subscription key is provided, then the result will be successful: