[英]Azure API Management - How to execute product policy when product does not require subscription?
I have a product published that does not requires a subscription.我发布了不需要订阅的产品。 The 4 APIs that compose it also does not.
组成它的 4 个 API 也没有。 How can I define policies on a product level?
如何在产品级别定义策略?
Such policies seem to work only when both the APIs AND the product require subscription AND the request is made using the product subscription key.此类策略似乎仅在 API和产品都需要订阅并且使用产品订阅密钥发出请求时才有效。
Prerequisites:先决条件:
If above points are true, just call your API without Ocp-Apim-Subscription-Key header and APIM will automatically execute API and attached product policies.如果以上几点属实,只需在没有Ocp-Apim-Subscription-Key header 的情况下调用您的 API,APIM 将自动执行 API 和附加的产品策略。 If you provide Ocp-Apim-Subscription-Key with correct value, like for example administrator subscription key, APIM will only execute API policies.
如果您为 Ocp-Apim-Subscription-Key 提供正确的值,例如管理员订阅密钥,APIM 将仅执行 API 策略。
To reduce the frustration it is important to understand policy order execution.为了减少挫败感,了解策略命令的执行很重要。 Read the whole article here but in short the order is:
在这里阅读整篇文章,但简而言之,顺序是:
One last thing, if non subscription product is attached to non subscription API and its policies are executed automatically, you may wonder what happens if we add second open product to the API?最后一件事,如果非订阅产品附加到非订阅 API 并且其策略自动执行,您可能想知道如果我们将第二个开放产品添加到 API 会发生什么? Policies from which product will be executed?
将从哪个产品执行策略? Turns out, this is not possible (what makes sense).
事实证明,这是不可能的(这是有道理的)。 Attempting to add second open product will result in following error:
尝试添加第二个打开的产品将导致以下错误:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.