How to call/retrieve value from Azure app config through APIM policy

Amit Srivastava 60 Reputation points

Hi Team, need help, I want to make call from APIM policy(c# code) to Azure app config to retrieve value against a key. But I am unable to figure out how to achieve this. Can you please help me. Thanks in advance

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
1,792 questions
Azure App Configuration
Azure App Configuration
An Azure service that provides hosted, universal storage for Azure app configurations.
209 questions
0 comments No comments
{count} votes

Accepted answer
  1. MuthuKumaranMurugaachari-MSFT 22,156 Reputation points

    Amit Srivastava Thank you for posting your question in Microsoft Q&A.

    Here are the steps you can follow to achieve this:

    1. Enable System-assigned Managed Identity for your APIM instance as described Use managed identities in Azure API Management.
    2. Assign Azure App Configuration Data Reader role for the managed identity as per doc: AD Authentication
    3. Then write a custom policy to send request to Azure App Configuration Rest API ( to get the key value and use authentication-managed-identity policy to generate authorization token. Refer sample code snippet below: (replace <app-config-name> and testkeyname with actual value)
       <send-request mode="new" timeout="20" ignore-error="false" response-variable-name="tokenstate">
                   <authentication-managed-identity resource="" ignore-error="false" />
               <set-variable name="keyValue" value="@(((IResponse)context.Variables["tokenstate"]).Body.As<JObject>()["value"])" />

    Note, the above code snippet is a sample policy for your reference, and you can customize it based on your need. If you face any issues, let me know. I hope this helps with your question.

    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.

    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful