NamedValue is not accessible in APIM

Sukhmeet Bhatia 0 Reputation points
2024-08-30T13:48:40.37+00:00

I am trying to access Named Value in APIM Set-variable policy in Inbound.

I tried to access it using context.Variables, context.namedValues and also tried using {{}} directly but none of them work and I get the error the name does not exist in the current context

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

1 answer

Sort by: Most helpful
  1. LeelaRajeshSayana-MSFT 14,831 Reputation points Microsoft Employee
    2024-08-30T22:24:48.4+00:00

    Hi @Sukhmeet Bhatia Greetings! Welcome to Microsoft Q&A forum. Thank you for posting this question here.

    Just wanted to check if you have created the Named Value as Plain Value type or a Secret If someone else has created the Named Value as Secret, please ensure you have access to the Key-Vault where the secret is stored. Please refer the article Add a key vault secret to API Management for more information.

    If you have defined a Plain Named Value, you should be able to access it by using {{}} per the documentation.

    Here is an example of how a Named Value can be used

    <set-header name="{{ContosoHeader}}" exists-action="override">
      <value>{{ContosoHeaderValue}}</value>
    </set-header>
    
    
    

    Notice that both ContosoHeader and ContosoHeaderValue are Named which are referenced in the above policy. If the Named Value is not accessed within the <value> tag, they need to be enclosed with double quotation.

    If you still face additional issues, please share the type of Named Value you are trying to use and the policy statement through which you are accessing the named space.

    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.