question

BalakrishnaSudabathula-2499 avatar image
0 Votes"
BalakrishnaSudabathula-2499 asked MayankBargali-MSFT commented

How to read a value from NamedValues in APIM

How to use Named Values in Azure API Management policies

In this article explains you can reference named values properties with the sentence: {<!-- -->{NamedValuePropertyReference}}

But, I need something like this:

{<!-- -->{$"dinamcallyyCreatedPropertyReference"}}

Here the Key is the client application id which we are getting from the azp claim in the JWT token. Based on the key we need to add client application name to one of the custom header in the APIM.

Thanks.

azure-api-management
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MayankBargali-MSFT avatar image
1 Vote"
MayankBargali-MSFT answered

Hi @BalakrishnaSudabathula-2499

Welcome to Microsoft Q&A! Thanks for posting the question.

This is not supported and not possible to support as described in this feature request as properties are resolved at compile time.

The Workarounds would be to either

  • Store named values as a JSON string or a CSV string with key=value pairs. Then use policy expressions to parse and fetch the required value.

  • Use control flow policies for making run time decisions.

  • For complex cases, you can offload the work to a function app but use value caching policies for improved latency if possible

Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AzureDeveloper-6812 avatar image
0 Votes"
AzureDeveloper-6812 answered MayankBargali-MSFT commented

I have a question here. How do you store the Named Values in JSON format?

For Example, I have a key "123" and value "abc" ,and another key "234" and value as "bcd".

95713-image.png



image.png (17.9 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@AzureDeveloper-6812 You need to define vaue as json object [{"123":"abc"},{"234":"bcd"}]
If you need any help feel free to create a new Microsoft Q&A post so community members will be happy to assist you.

0 Votes 0 ·