An Azure service that provides a hybrid, multi-cloud management platform for APIs.
Stavros Koureas hi, thx for sharing urs issue here at Q&A portal,
Yep, ur read is right. APIM resolves context.Subscription before ur inbound policy changes the header, so setting Ocp-Apim-Subscription-Key inside the policy won’t make APIM re-run subscription lookup. In other words, by the time ur policy runs, APIM has already decided if the request has a valid subscription or not. So this part can extract the key fine, but it won’t populate context.Subscription.
For APIM’s built-in subscription tracking, the client needs to send the key in the configured subscription key header/query param from the start. https://learn.microsoft.com/en-us/azure/api-management/api-management-subscriptions
For tools that only send Authorization Bearer <key>, best workaround is to set Subscription required = false, parse the Bearer value yourself, then use policies like quota-by-key / rate-limit-by-key with ur extracted clientKey as the counter key. That won’t populate APIM’s native context.Subscription, but u can still meter/limit per user/key. https://learn.microsoft.com/en-us/azure/api-management/quota-by-key-policy
If u need native APIM subscription analytics, the tool has to send Ocp-Apim-Subscription-Key, api-key, or whatever header u configured in the API settings. Rewriting Authorization into that header inside inbound policy is too late for native subscription matching. For VS Code/Copilot-style clients, check if the tool config lets u add custom headers. If yes, add the APIM subscription key as api-key or Ocp-Apim-Subscription-Key and keep Authorization for whatever the tool expects. If it can’t send custom headers, u prob need custom policy-based metering instead of APIM subscription analytics.
So yeah, not a bug in ur policy. It’s just APIM pipeline order biting u. Classic ‘works exactly as designed, still hurts’ case.
rgds,
Alex
&
If my answer was helpful pls mark it and additional thx if u follow me at Q&A portal