Is it possible to set rate limit value using app config in APIM policy

Neethu Nath 25 Reputation points
2023-08-07T06:49:23.8933333+00:00
 <send-request mode="new" timeout="20" ignore-error="false" response-variable-name="ResponseKey">
            <set-url>@("{{BaseUrl}}ConnectionKey")</set-url>
            <set-method>GET</set-method>
            <authentication-managed-identity resource="https://azconfig.io" ignore-error="false" />
        </send-request>
        <set-variable name="keyValue" value="@(((IResponse)context.Variables["ResponseKey"]).Body.As<JObject>()["value"])" />

<rate-limit calls="@(context.Variables.GetValueOrDefault("keyValue"))" renewal-period="60" />

I want to set rate-limit calls value from app config.

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
2,365 questions
0 comments No comments
{count} votes

Accepted answer
  1. Viknesh Anamala 75 Reputation points
    2023-08-07T16:18:06.9533333+00:00

    Rather than setting it at app config, why not consider setting it at named value in api management which then can be used in the policy. See this

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. MuthuKumaranMurugaachari-MSFT 22,421 Reputation points
    2023-08-07T15:11:38.5433333+00:00

    Neethu Nath Thanks for posting your question in Microsoft Q&A. It is possible to retrieve the value from azure app configuration using the sample policy snippet above and the detailed steps are described in other thread discussion. However, unfortunately, calls attribute in the rate-limit policy doesn't allow policy expression and it has to be a static value or a named value. So, you cannot set the value using context.Variables policy expression in the calls attribute.

    User's image

    If you are interested in this feature or any feedback, please submit it directly to our product team via https://aka.ms/apimwish and others with similar interest can upvote too. I will also share it internally and add a note in the doc. I hope this helps and let me know if any questions.


    If you found the answer to your question helpful, please take a moment to mark it as "Yes" for others to benefit from your experience. Or simply add a comment tagging me and would be happy to answer your questions.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.