Actually I'm trying to re-new a quota for specific client because he exceed the quota, but in same time i don't want to reset it for all client only for this one , Also without changing the subscription key .
the code below is not working fine i try to test it , does not reaching the limit exactly sometimes reaching more than the quota and sometimes less than and it's not small different it's huge different
<choose>
<when condition="@(context.Subscription.Id == "")">
<quota-by-key calls="20" renewal-period="500" counter-key="@(context.Subscription.Key)" />
</when>
<otherwise />
</choose>
I have used the same policy at my end by creating a new subscription key and it worked as expected for me.
Please verify if you are using the correct subscription id. By default, APIM takes the Built-in all-access subscription subscription key if you haven't provided ocp-apim-subscription-key in the request header for any other subscription key. For Built-in all-access subscription, subscription id value is master.
You can check the subscription key name and id which is being used by your API with the help of below policy-
<set-variable name="ID" value="@(context.Subscription.Id)" />
<set-variable name="Name" value="@(context.Subscription.Name)" />
You can see the values in Trace
Policy
<choose>
<when condition="@(context.Subscription.Id== "test")">
<quota-by-key calls="2" renewal-period="300" counter-key="@(context.Subscription.Key)" />
</when>
</choose>
Test
Trace
You can refer to this link too.