Reputation: 8009
Is it possible to, within policy, get the base url and that with version hightlighted below:
A url is needed like below:
@(base url with version identifier)
Above is used in find-and-replace
element below:
<policies>
<inbound>
<base />
<set-backend-service base-url="https://my.com/oidc" />
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
<find-and-replace from="https://thirdparty/certs"
to="@(base url with version identifier)/certs" />
</outbound>
<on-error>
<base />
</on-error>
</policies>
Update
How can I get the base url too? The reason is that sometimes, the versioned url is not specified, in this case, only the base url is used to repalce.
https://learn.microsoft.com/en-us/azure/api-management/api-management-policy-expressions#ref-iurl
Upvotes: 0
Views: 2975
Reputation: 1704
You can get the base url with version using the below code snippet
@{
var methodRoute = context.Request.Url.ToString().Replace(context.Api.ServiceUrl.ToString(),"");
var frontEndServiceUrl = context.Request.OriginalUrl.ToString().Replace(methodRoute,"");
}
Upvotes: 1