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 == "North Europe" ? "{{WEB-PROXY-North-Europe}}" : "{{WEB-PROXY}}")" />
</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?