Rustang
Rustang

Reputation: 546

In Azure API Management, is it possible to parameterise a Web Service URL?

Is it possible to populate the Web Service URL based off some parameter / variable that gets sent to the Base URL?

I want to be able to forward different inbound requests to API Management to different target servers, without having to create new APIs for each new server.

enter image description here

Upvotes: 1

Views: 1076

Answers (1)

Markus Meyer
Markus Meyer

Reputation: 3937

You can specify different backends with a policy. There you can add your custom logic for different query values, params, headers,...

<policies>
    <inbound>
        <choose>
            <when condition="@(context.Request.Url.Query.GetValueOrDefault("version") == "2013-05")">
                <set-backend-service base-url="http://contoso.com/api/8.2/" />
            </when>
            <when condition="@(context.Request.Url.Query.GetValueOrDefault("version") == "2014-03")">
                <set-backend-service base-url="http://contoso.com/api/9.1/" />
            </when>
        </choose>
        <base />
    </inbound>
    <outbound>
        <base />
    </outbound>
</policies>

API Management transformation policies

Upvotes: 1

Related Questions