Azure Api "NameValue" within "NameValue" is not working

416 Views Asked by At

Trying to use Azure API "NameValue" variable within another variable.

//NameValue variable 1 
Namedvalue_URL_Name: sts://domain.com

//NameValue variable 2 that using above variable within.   
Namedvalue_withinNameValue_Name:
@{

var u = "{{Namedvalue_URL_Name}}";
return u;
}

Azure Policy:

<set-variable name="var" value={{Namedvalue_withinNameValue_Name}}/>

response return for the value (string)context.Variabls["var"] as "{{Namedvalue_URL_Name}}" but expected result as sts://domain.com.

2

There are 2 best solutions below

0
On

Starting 28-11-2018, we are facing an issue where in liquid templates are not able to resolve the NameValues.

Code what we have: Here ProcessAccountId is NameValue pair with value "Username"

   <set-body template="liquid">
        <soap:Envelope xmlns:soap="http://abc" xmlns:htt="http://xyz" xmlns:ino="http://123" xmlns:ino1="http://456">
            <soap:Header>
                <htt:UserNameToken>
                    <htt:UserName>{{ProcessAccountId}}</htt:UserName>
                    <!--Optional:-->
                    <htt:Password>
                    </htt:Password>
                    <!--Optional:-->
                    <htt:Nonce>
                    </htt:Nonce>
                </htt:UserNameToken>
            </soap:Header>

it is resolving to below where NameValue is replaced with empty string.

        <soap:Envelope xmlns:soap="http://abc" xmlns:htt="http://xyz" xmlns:ino="http://123" xmlns:ino1="http://456">
            <soap:Header>
                <htt:UserNameToken>
                    <htt:UserName></htt:UserName>
                    <!--Optional:-->
                    <htt:Password>
                    </htt:Password>
                    <!--Optional:-->
                    <htt:Nonce>
                    </htt:Nonce>
                </htt:UserNameToken>
            </soap:Header>
0
On

You can define Named Values as enter image description here

and then when you refer to the paramB in the policy file

<set-variable name="variable3" value="{{paramB}}" />

it gives you the value of the paramA

set-variable (0.003 ms)
{
    "message": "Context variable was successfully set.",
    "name": "variable3",
    "value": "valueA"
}