0

I'm encountering an error in Azure API Management when trying to use a conditional expression to set a proxy URL based on the deployment region. The proxy URL is constructed using named values.

The Policy

<send-request mode="new" response-variable-name="result" timeout="10" ignore-error="true">
    <set-url>@("https://management.azure.com/subscriptions/.../resourceGroups/....")</set-url>
    <set-method>GET</set-method>
    <set-header name="Accept" exists-action="override">
        <value>application/yaml</value>
    </set-header>
    <set-header name="accept-encoding" exists-action="override">
        <value>gzip, deflate</value>
    </set-header>
    <set-header name="X-Forwarded-For" exists-action="delete" />
    <authentication-managed-identity resource="https://management.azure.com/" />
    <proxy url="@(context.Deployment.Region == &quot;North Europe&quot; ? &quot;{{WEB-PROXY-North-Europe}}&quot; : &quot;{{WEB-PROXY}}&quot;)" />
</send-request>

The Error

{
    "source": "proxy",
    "timestamp": "2025-09-02T14:23:46.6745213Z",
    "elapsed": "00:00:00.0013593",
    "data": {
        "messages": [
            {
                "message": "Expression value is invalid.",
                "expression": "context.Deployment.Region == \"North Europe\" ? \"http://10.xxx.xxx.x:xxxx\" : \"http://10.xxx.xxx.x:xxxx\"",
                "value": "http://xxx.xxx.x:xxxx",
                "details": "Value is not a valid absolute URL scheme."
            },
            "Expression value is invalid. Value is not a valid absolute URL scheme."
        ]
    }
}

What I've Tried

The named values {{WEB-PROXY-North-Europe}} and {{WEB-PROXY}} are configured in API Management and contain URLs in the format http://10.xxx.xxx.x:xxxx.

The expression seems to be evaluating correctly (as shown in the error where it replaces the named values with actual HTTP URLs), but it's still throwing the "Value is not a valid absolute URL scheme" error.

Environment

  • Azure API Management
  • Using managed identity authentication
  • Named values configured for proxy URLs

Question

Why is the proxy URL being rejected as invalid even though it appears to be a valid HTTP URL? How can I properly configure a conditional proxy URL using named values in Azure API Management?

1
  • <set-url>@("management.azure.com/subscriptions/..../resourceGroups/…> <set-method>GET</set-method> <set-header name="Accept" exists-action="override"><value>application/yaml</value></set-header> <set-header name="accept-encoding" exists-action="override"><value>gzip, deflate</value></set-header> <set-header name="X-Forwarded-For" exists-action="delete" /> Explicit Type Cast Alternatively, you can try an explicit type cast on result of ternary expression. This forces the policy engine to resolve entire expression and its components into a string before validation. Commented Sep 9 at 21:20

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.